Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions types/react/test/tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,15 @@ function elementTypeTests() {
}
}

const ReturnPromiseReactNode = async ({ children }: { children?: React.ReactNode }) => children;
const FCPromiseReactNode: React.FC = ReturnReactNode;
class RenderPromiseReactNode extends React.Component<{ children?: React.ReactNode }> {
// @ts-expect-error class components cannot render async
async render() {
return this.props.children;
}
}

const ReturnWithLegacyContext = (props: { foo: string }, context: { bar: number }) => {
return (
<div>
Expand Down Expand Up @@ -865,6 +874,13 @@ function elementTypeTests() {
// Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
React.createElement(RenderPromise);

// @ts-expect-error See https://github.com/microsoft/TypeScript/issues/59111
<ReturnPromiseReactNode />;
// @ts-expect-error See https://github.com/microsoft/TypeScript/issues/59111
React.createElement(ReturnPromiseReactNode);
<FCPromiseReactNode />;
React.createElement(FCPromiseReactNode);

<ReturnWithLegacyContext foo="one" />;
React.createElement(ReturnWithLegacyContext, { foo: "one" });

Expand Down
17 changes: 17 additions & 0 deletions types/react/ts5.0/test/tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,16 @@ function elementTypeTests() {
}
}

const ReturnPromiseReactNode = async ({ children }: { children?: React.ReactNode }) => children;
// @ts-expect-error experimental release channel only
const FCPromiseReactNode: React.FC = ReturnReactNode;
class RenderPromiseReactNode extends React.Component<{ children?: React.ReactNode }> {
// @ts-expect-error class components cannot render async
async render() {
return this.props.children;
}
}

const ReturnWithLegacyContext = (props: { foo: string }, context: { bar: number }) => {
return (
<div>
Expand Down Expand Up @@ -865,6 +875,13 @@ function elementTypeTests() {
// Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
React.createElement(RenderPromise);

// @ts-expect-error See https://github.com/microsoft/TypeScript/issues/59111
<ReturnPromiseReactNode />;
// @ts-expect-error See https://github.com/microsoft/TypeScript/issues/59111
React.createElement(ReturnPromiseReactNode);
<FCPromiseReactNode />;
React.createElement(FCPromiseReactNode);

<ReturnWithLegacyContext foo="one" />;
React.createElement(ReturnWithLegacyContext, { foo: "one" });

Expand Down