Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Intrinsics with colon no longer type-checked #53784

Closed
wants to merge 4 commits into from
Closed
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
11 changes: 11 additions & 0 deletions tests/baselines/reference/jsxElementType.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,15 @@ tests/cases/compiler/jsxElementType.tsx(99,2): error TS2304: Cannot find name 'U
<Unresolved foo="abc" />;
~~~~~~~~~~
!!! error TS2304: Cannot find name 'Unresolved'.

// regression test for intrinsic containing `:`
declare global {
namespace JSX {
interface IntrinsicElements {
['fbt:enum']: { knownProp: string };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this needs to be declared another way now that #47356 has landed? But even if we drop support for that, the error message currently produced is not helpful. It silently treats <fbt:enum /> as any.

}
}
}

<fbt:enum knownProp="accepted" unknownProp="rejected" />;

12 changes: 12 additions & 0 deletions tests/baselines/reference/jsxElementType.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {

<Unresolved />;
<Unresolved foo="abc" />;

// regression test for intrinsic containing `:`
declare global {
namespace JSX {
interface IntrinsicElements {
['fbt:enum']: { knownProp: string };
}
}
}

<fbt:enum knownProp="accepted" unknownProp="rejected" />;


//// [jsxElementType.js]
Expand Down Expand Up @@ -231,3 +242,4 @@ function f1(Component) {
}
React.createElement(Unresolved, null);
React.createElement(Unresolved, { foo: "abc" });
React.createElement("fbt:enum", { knownProp: "accepted", unknownProp: "rejected" });
28 changes: 25 additions & 3 deletions tests/baselines/reference/jsxElementType.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ type NewReactJSXElementConstructor<P> =
>P : Symbol(P, Decl(jsxElementType.tsx, 16, 35))

declare global {
>global : Symbol(global, Decl(jsxElementType.tsx, 18, 48))
>global : Symbol(global, Decl(jsxElementType.tsx, 18, 48), Decl(jsxElementType.tsx, 98, 25))

namespace JSX {
>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12), Decl(jsxElementType.tsx, 20, 16))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12), Decl(jsxElementType.tsx, 20, 16), Decl(jsxElementType.tsx, 101, 16))

type ElementType = string | NewReactJSXElementConstructor<any>;
>ElementType : Symbol(ElementType, Decl(jsxElementType.tsx, 21, 17))
>NewReactJSXElementConstructor : Symbol(NewReactJSXElementConstructor, Decl(jsxElementType.tsx, 13, 30))

interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67))
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 102, 17))

['my-custom-element']: React.DOMAttributes<unknown>;
>['my-custom-element'] : Symbol(IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33))
Expand Down Expand Up @@ -272,3 +272,25 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
<Unresolved foo="abc" />;
>foo : Symbol(foo, Decl(jsxElementType.tsx, 98, 11))

// regression test for intrinsic containing `:`
declare global {
>global : Symbol(global, Decl(jsxElementType.tsx, 18, 48), Decl(jsxElementType.tsx, 98, 25))

namespace JSX {
>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12), Decl(jsxElementType.tsx, 20, 16), Decl(jsxElementType.tsx, 101, 16))

interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 102, 17))

['fbt:enum']: { knownProp: string };
>['fbt:enum'] : Symbol(IntrinsicElements['fbt:enum'], Decl(jsxElementType.tsx, 103, 33))
>'fbt:enum' : Symbol(IntrinsicElements['fbt:enum'], Decl(jsxElementType.tsx, 103, 33))
>knownProp : Symbol(knownProp, Decl(jsxElementType.tsx, 104, 21))
}
}
}

<fbt:enum knownProp="accepted" unknownProp="rejected" />;
>knownProp : Symbol(knownProp, Decl(jsxElementType.tsx, 109, 9))
>unknownProp : Symbol(unknownProp, Decl(jsxElementType.tsx, 109, 30))

21 changes: 21 additions & 0 deletions tests/baselines/reference/jsxElementType.types
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,24 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
>Unresolved : any
>foo : string

// regression test for intrinsic containing `:`
declare global {
>global : any

namespace JSX {
interface IntrinsicElements {
['fbt:enum']: { knownProp: string };
>['fbt:enum'] : { knownProp: string; }
>'fbt:enum' : "fbt:enum"
>knownProp : string
}
}
}

<fbt:enum knownProp="accepted" unknownProp="rejected" />;
><fbt:enum knownProp="accepted" unknownProp="rejected" /> : JSX.Element
>fbt : any
>enum : any
>knownProp : string
>unknownProp : string

11 changes: 11 additions & 0 deletions tests/cases/compiler/jsxElementType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,14 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {

<Unresolved />;
<Unresolved foo="abc" />;

// regression test for intrinsic containing `:`
declare global {
namespace JSX {
interface IntrinsicElements {
['fbt:enum']: { knownProp: string };
}
}
}

<fbt:enum knownProp="accepted" unknownProp="rejected" />;