Skip to content

Commit

Permalink
🤖 Pick PR #53784 ([test] Intrinsics with colon no lon...) into revert…
Browse files Browse the repository at this point in the history
…-47356-feat/7411 (#53793)

Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
  • Loading branch information
TypeScript Bot and eps1lon authored Apr 15, 2023
1 parent fc1beb0 commit a674d0b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 3 deletions.
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 };
}
}
}

<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" />;

0 comments on commit a674d0b

Please sign in to comment.