diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f005b93feeab..1a196b0dbff43 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -346,6 +346,7 @@ namespace ts { }); let jsxElementType: Type; + let jsxStatelessElementType: Type; let _jsxNamespace: string; let _jsxFactoryEntity: EntityName; @@ -358,7 +359,8 @@ namespace ts { ElementAttributesPropertyNameContainer: "ElementAttributesProperty", Element: "Element", IntrinsicAttributes: "IntrinsicAttributes", - IntrinsicClassAttributes: "IntrinsicClassAttributes" + IntrinsicClassAttributes: "IntrinsicClassAttributes", + StatelessElement: "StatelessElement" }; const subtypeRelation = createMap(); @@ -12197,13 +12199,13 @@ namespace ts { function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement: JsxOpeningLikeElement, elementType: Type, elemInstanceType: Type, elementClassType?: Type): Type { Debug.assert(!(elementType.flags & TypeFlags.Union)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + if (jsxStatelessElementType) { // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. const callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); if (callSignature !== unknownSignature) { const callReturnType = callSignature && getReturnTypeOfSignature(callSignature); let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { @@ -12231,7 +12233,7 @@ namespace ts { Debug.assert(!(elementType.flags & TypeFlags.Union)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - if (jsxElementType) { + if (jsxStatelessElementType) { // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. const candidatesOutArray: Signature[] = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); @@ -12240,7 +12242,7 @@ namespace ts { for (const candidate of candidatesOutArray) { const callReturnType = getReturnTypeOfSignature(candidate); const paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { let shouldBeCandidate = true; for (const attribute of openingLikeElement.attributes.properties) { if (isJsxAttribute(attribute) && @@ -21280,6 +21282,7 @@ namespace ts { globalRegExpType = getGlobalType("RegExp"); jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + jsxStatelessElementType = getExportedTypeFromNamespace("JSX", JsxNames.StatelessElement) getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt index 47d0b8c839ada..a5c71ebd5cccd 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(16,15): error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(17,15): error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. Types of property 'foo' are incompatible. Type '"f"' is not assignable to type '"A" | "B" | "C"'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(17,15): error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(18,15): error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. Types of property 'foo' are incompatible. Type '"f"' is not assignable to type '"A" | "B" | "C"'. @@ -9,6 +9,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStr ==== tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx (2 errors) ==== namespace JSX { + export type StatelessElement = JSX.Element | null; export interface IntrinsicElements { span: {}; } diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.js b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.js index d1b2ebf5ae544..68874c5881fdc 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.js +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.js @@ -1,6 +1,7 @@ //// [contextuallyTypedStringLiteralsInJsxAttributes01.tsx] namespace JSX { + export type StatelessElement = JSX.Element | null; export interface IntrinsicElements { span: {}; } @@ -27,6 +28,7 @@ var FooComponent = function (props) { return {props.foo}; }; //// [contextuallyTypedStringLiteralsInJsxAttributes01.d.ts] declare namespace JSX { + type StatelessElement = JSX.Element | null; interface IntrinsicElements { span: {}; } diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt index 79b4a55f10245..8003682da691e 100644 --- a/tests/baselines/reference/tsxAttributeResolution14.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt @@ -9,6 +9,7 @@ tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type '{ justRandomPro ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== declare module JSX { + type StatelessElement = JSX.Element | null; interface Element { } interface IntrinsicElements { div: any; diff --git a/tests/baselines/reference/tsxAttributeResolution14.js b/tests/baselines/reference/tsxAttributeResolution14.js index d920179458cc0..9e04f2610670d 100644 --- a/tests/baselines/reference/tsxAttributeResolution14.js +++ b/tests/baselines/reference/tsxAttributeResolution14.js @@ -3,6 +3,7 @@ //// [react.d.ts] declare module JSX { + type StatelessElement = JSX.Element | null; interface Element { } interface IntrinsicElements { div: any; diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols b/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols index a0efe4f9dbe31..df08f6ed1fc7f 100644 --- a/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols +++ b/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols @@ -20,8 +20,8 @@ class Poisoned extends React.Component { >render : Symbol(Poisoned.render, Decl(file.tsx, 6, 50)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols b/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols index 7bcdc7ccfa20d..abfdfc939eaec 100644 --- a/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols +++ b/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols @@ -20,8 +20,8 @@ class Poisoned extends React.Component { >render : Symbol(Poisoned.render, Decl(file.tsx, 6, 50)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution1.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution1.symbols index d14e939ed7554..13e6983c770f0 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution1.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution1.symbols @@ -13,8 +13,8 @@ class Poisoned extends React.Component<{}, {}> { >render : Symbol(Poisoned.render, Decl(file.tsx, 3, 48)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution11.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution11.symbols index c29ca5cd66259..24bf7fa85313d 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution11.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution11.symbols @@ -49,8 +49,8 @@ class OverWriteAttr extends React.Component { >render : Symbol(OverWriteAttr.render, Decl(file.tsx, 18, 55)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution3.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution3.symbols index 7cf151f022bb4..74be71aca2944 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution3.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution3.symbols @@ -24,8 +24,8 @@ class Poisoned extends React.Component { >render : Symbol(Poisoned.render, Decl(file.tsx, 8, 58)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols index 6d01f6f1f3981..5b2c4333c91b8 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols @@ -24,8 +24,8 @@ class Poisoned extends React.Component { >render : Symbol(Poisoned.render, Decl(file.tsx, 8, 58)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } @@ -57,8 +57,8 @@ class EmptyProp extends React.Component<{}, {}> { >render : Symbol(EmptyProp.render, Decl(file.tsx, 22, 49)) return
Default hi
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution8.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution8.symbols index 6a9f9c05fce2d..a116277aa7bda 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution8.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution8.symbols @@ -46,8 +46,8 @@ class OverWriteAttr extends React.Component { >render : Symbol(OverWriteAttr.render, Decl(file.tsx, 18, 55)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution9.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution9.symbols index e58e92cd29a65..78fc5af6d970c 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution9.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution9.symbols @@ -24,8 +24,8 @@ class Opt extends React.Component { >render : Symbol(Opt.render, Decl(file.tsx, 8, 51)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents3.symbols b/tests/baselines/reference/tsxStatelessFunctionComponents3.symbols index d42d7aeaf1221..e942917c8645b 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents3.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponents3.symbols @@ -6,7 +6,7 @@ import React = require('react'); const Foo = (props: any) =>
; >Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) >props : Symbol(props, Decl(file.tsx, 3, 13)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) // Should be OK const foo = ; @@ -20,14 +20,14 @@ var MainMenu: React.StatelessComponent<{}> = (props) => (
>React : Symbol(React, Decl(file.tsx, 0, 0)) >StatelessComponent : Symbol(React.StatelessComponent, Decl(react.d.ts, 197, 40)) >props : Symbol(props, Decl(file.tsx, 9, 46)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))

Main Menu

->h3 : Symbol(JSX.IntrinsicElements.h3, Decl(react.d.ts, 2409, 48)) ->h3 : Symbol(JSX.IntrinsicElements.h3, Decl(react.d.ts, 2409, 48)) +>h3 : Symbol(JSX.IntrinsicElements.h3, Decl(react.d.ts, 2412, 48)) +>h3 : Symbol(JSX.IntrinsicElements.h3, Decl(react.d.ts, 2412, 48))
); ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) var App: React.StatelessComponent<{ children }> = ({children}) => ( >App : Symbol(App, Decl(file.tsx, 13, 3)) @@ -37,12 +37,12 @@ var App: React.StatelessComponent<{ children }> = ({children}) => ( >children : Symbol(children, Decl(file.tsx, 13, 52))
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) >MainMenu : Symbol(MainMenu, Decl(file.tsx, 9, 3))
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) ); diff --git a/tests/baselines/reference/tsxUnionElementType1.symbols b/tests/baselines/reference/tsxUnionElementType1.symbols index cb743ff273545..8c1aba504161c 100644 --- a/tests/baselines/reference/tsxUnionElementType1.symbols +++ b/tests/baselines/reference/tsxUnionElementType1.symbols @@ -9,8 +9,8 @@ function SFC1(prop: { x: number }) { >x : Symbol(x, Decl(file.tsx, 3, 21)) return
hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) }; @@ -20,8 +20,8 @@ function SFC2(prop: { x: boolean }) { >x : Symbol(x, Decl(file.tsx, 7, 21)) return

World

; ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) } var SFCComp = SFC1 || SFC2; diff --git a/tests/baselines/reference/tsxUnionElementType5.symbols b/tests/baselines/reference/tsxUnionElementType5.symbols index ed1e468271d77..f3b2e7ca01b08 100644 --- a/tests/baselines/reference/tsxUnionElementType5.symbols +++ b/tests/baselines/reference/tsxUnionElementType5.symbols @@ -7,16 +7,16 @@ function EmptySFC1() { >EmptySFC1 : Symbol(EmptySFC1, Decl(file.tsx, 1, 32)) return
hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } function EmptySFC2() { >EmptySFC2 : Symbol(EmptySFC2, Decl(file.tsx, 5, 1)) return
Hello
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } function SFC2(prop: { x: boolean }) { @@ -25,8 +25,8 @@ function SFC2(prop: { x: boolean }) { >x : Symbol(x, Decl(file.tsx, 11, 21)) return

World

; ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) } var EmptySFCComp = EmptySFC1 || EmptySFC2; diff --git a/tests/baselines/reference/tsxUnionTypeComponent1.symbols b/tests/baselines/reference/tsxUnionTypeComponent1.symbols index be4bc204da3ea..d4c0a25b484b1 100644 --- a/tests/baselines/reference/tsxUnionTypeComponent1.symbols +++ b/tests/baselines/reference/tsxUnionTypeComponent1.symbols @@ -39,8 +39,8 @@ class MyComponent extends React.Component { }/> >MyComponent : Symbol(MyComponent, Decl(file.tsx, 5, 1)) >AnyComponent : Symbol(AnyComponent, Decl(file.tsx, 15, 12)) ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2383, 43)) ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2383, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) // Component Class as Props class MyButtonComponent extends React.Component<{},{}> { diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx index 1e4418e7fba37..d680f72bad456 100644 --- a/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx +++ b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx @@ -3,6 +3,7 @@ //@filename: react.d.ts declare module JSX { + type StatelessElement = JSX.Element | null; interface Element { } interface IntrinsicElements { div: any; diff --git a/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx b/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx index 2235961086f7b..762883697e5cf 100644 --- a/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx +++ b/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx @@ -2,6 +2,7 @@ // @declaration: true namespace JSX { + export type StatelessElement = JSX.Element | null; export interface IntrinsicElements { span: {}; } diff --git a/tests/cases/fourslash/tsxCompletion12.ts b/tests/cases/fourslash/tsxCompletion12.ts index 542dbec2c2b7b..33a5e3dee7bd4 100644 --- a/tests/cases/fourslash/tsxCompletion12.ts +++ b/tests/cases/fourslash/tsxCompletion12.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxCompletion13.ts b/tests/cases/fourslash/tsxCompletion13.ts index 60964acbc5530..2bb17eb2ded4b 100644 --- a/tests/cases/fourslash/tsxCompletion13.ts +++ b/tests/cases/fourslash/tsxCompletion13.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxCompletionUnionElementType.ts b/tests/cases/fourslash/tsxCompletionUnionElementType.ts index 4a1044e20ac86..e466b4a22d8b4 100644 --- a/tests/cases/fourslash/tsxCompletionUnionElementType.ts +++ b/tests/cases/fourslash/tsxCompletionUnionElementType.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxFindAllReferences10.ts b/tests/cases/fourslash/tsxFindAllReferences10.ts index a027671ec3d4d..b2942c91f56ca 100644 --- a/tests/cases/fourslash/tsxFindAllReferences10.ts +++ b/tests/cases/fourslash/tsxFindAllReferences10.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxFindAllReferences7.ts b/tests/cases/fourslash/tsxFindAllReferences7.ts index b1f5231a19859..1f021dcc20e66 100644 --- a/tests/cases/fourslash/tsxFindAllReferences7.ts +++ b/tests/cases/fourslash/tsxFindAllReferences7.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxFindAllReferences9.ts b/tests/cases/fourslash/tsxFindAllReferences9.ts index 5ac6ad344d8c3..724c5239ce265 100644 --- a/tests/cases/fourslash/tsxFindAllReferences9.ts +++ b/tests/cases/fourslash/tsxFindAllReferences9.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts b/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts index d620b3585af8e..92449110aeb71 100644 --- a/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts +++ b/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxRename10.ts b/tests/cases/fourslash/tsxRename10.ts index 091f5aa976fe4..cec4135823277 100644 --- a/tests/cases/fourslash/tsxRename10.ts +++ b/tests/cases/fourslash/tsxRename10.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxRename11.ts b/tests/cases/fourslash/tsxRename11.ts index 97933dd0cc9b2..ddd39ddc9c2e7 100644 --- a/tests/cases/fourslash/tsxRename11.ts +++ b/tests/cases/fourslash/tsxRename11.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/cases/fourslash/tsxRename7.ts b/tests/cases/fourslash/tsxRename7.ts index b5d05e49bd36b..803d417603196 100644 --- a/tests/cases/fourslash/tsxRename7.ts +++ b/tests/cases/fourslash/tsxRename7.ts @@ -5,6 +5,7 @@ // @noLib: true //// declare module JSX { +//// type StatelessElement = JSX.Element | null; //// interface Element { } //// interface IntrinsicElements { //// } diff --git a/tests/lib/react.d.ts b/tests/lib/react.d.ts index b2b0783cf1533..2c1c7fb554d43 100644 --- a/tests/lib/react.d.ts +++ b/tests/lib/react.d.ts @@ -2359,6 +2359,9 @@ declare namespace JSX { interface ElementClass extends React.Component { render(): JSX.Element | null; } + + type StatelessElement = JSX.Element | null; + interface ElementAttributesProperty { props: {}; } interface IntrinsicAttributes extends React.Attributes { }