From 8ae55b412aac1b88a4fa066627e76849ede1d8ee Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 11 Feb 2016 09:37:24 -0800 Subject: [PATCH] Add failing test --- .../tsxAttributeResolution12.errors.txt | 51 +++++++++++++++++ .../reference/tsxAttributeResolution12.js | 55 +++++++++++++++++++ .../tsxAttributeResolution12.symbols | 47 ++++++++++++++++ .../reference/tsxAttributeResolution12.types | 49 +++++++++++++++++ .../jsx/tsxAttributeResolution12.tsx | 46 ++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 tests/baselines/reference/tsxAttributeResolution12.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution12.js create mode 100644 tests/baselines/reference/tsxAttributeResolution12.symbols create mode 100644 tests/baselines/reference/tsxAttributeResolution12.types create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution12.tsx diff --git a/tests/baselines/reference/tsxAttributeResolution12.errors.txt b/tests/baselines/reference/tsxAttributeResolution12.errors.txt new file mode 100644 index 00000000000..a6606080dbf --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution12.errors.txt @@ -0,0 +1,51 @@ +tests/cases/conformance/jsx/file.tsx(26,10): error TS2324: Property 'reqd' is missing in type 'IntrinsicAttributes & { reqd: any; }'. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } + interface IntrinsicAttributes { + ref?: string; + } + } + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + + declare class Component { + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + } + + + interface ComponentClass

{ + new (props?: P, context?: any): Component; + } + + declare module TestMod { + interface TestClass extends ComponentClass<{reqd: any}> { + } + var Test: TestClass; + } + + // Errors correctly + const T = TestMod.Test; + var t1 = ; + ~~~~~ +!!! error TS2324: Property 'reqd' is missing in type 'IntrinsicAttributes & { reqd: any; }'. + + // Should error + var t2 = ; + + \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution12.js b/tests/baselines/reference/tsxAttributeResolution12.js new file mode 100644 index 00000000000..05a854a7cbc --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution12.js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/jsx/tsxAttributeResolution12.tsx] //// + +//// [react.d.ts] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } + interface IntrinsicAttributes { + ref?: string; + } +} + +//// [file.tsx] + +declare class Component { + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; +} + + +interface ComponentClass

{ + new (props?: P, context?: any): Component; +} + +declare module TestMod { + interface TestClass extends ComponentClass<{reqd: any}> { + } + var Test: TestClass; +} + +// Errors correctly +const T = TestMod.Test; +var t1 = ; + +// Should error +var t2 = ; + + + +//// [file.jsx] +// Errors correctly +var T = TestMod.Test; +var t1 = ; +// Should error +var t2 = ; diff --git a/tests/baselines/reference/tsxAttributeResolution12.symbols b/tests/baselines/reference/tsxAttributeResolution12.symbols new file mode 100644 index 00000000000..b638e6340bc --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution12.symbols @@ -0,0 +1,47 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module JSX { +>JSX : Symbol(JSX, Decl(react.d.ts, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(react.d.ts, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(react.d.ts, 2, 22)) + } + interface ElementAttributesProperty { +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(react.d.ts, 4, 2)) + + props; +>props : Symbol(props, Decl(react.d.ts, 5, 38)) + } + interface IntrinsicAttributes { +>IntrinsicAttributes : Symbol(IntrinsicAttributes, Decl(react.d.ts, 7, 2)) + + ref?: string; +>ref : Symbol(ref, Decl(react.d.ts, 8, 32)) + } +} + +=== tests/cases/conformance/jsx/file.tsx === +declare module TestMod { +>TestMod : Symbol(TestMod, Decl(file.tsx, 0, 0)) + + interface TestClass { +>TestClass : Symbol(TestClass, Decl(file.tsx, 0, 24)) + + props: { reqd: any }; +>props : Symbol(props, Decl(file.tsx, 1, 22)) +>reqd : Symbol(reqd, Decl(file.tsx, 2, 10)) + } + var Test: TestClass; +>Test : Symbol(Test, Decl(file.tsx, 4, 4)) +>TestClass : Symbol(TestClass, Decl(file.tsx, 0, 24)) +} + +// Should error +var test = +>test : Symbol(test, Decl(file.tsx, 8, 3)) +>Test : Symbol(TestMod.TestClass, Decl(file.tsx, 0, 24)) + + diff --git a/tests/baselines/reference/tsxAttributeResolution12.types b/tests/baselines/reference/tsxAttributeResolution12.types new file mode 100644 index 00000000000..ced4105d602 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution12.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/jsx/react.d.ts === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + } + interface ElementAttributesProperty { +>ElementAttributesProperty : ElementAttributesProperty + + props; +>props : any + } + interface IntrinsicAttributes { +>IntrinsicAttributes : IntrinsicAttributes + + ref?: string; +>ref : string + } +} + +=== tests/cases/conformance/jsx/file.tsx === +declare module TestMod { +>TestMod : typeof TestMod + + interface TestClass { +>TestClass : TestClass + + props: { reqd: any }; +>props : { reqd: any; } +>reqd : any + } + var Test: TestClass; +>Test : TestClass +>TestClass : TestClass +} + +// Should error +var test = +>test : JSX.Element +> : JSX.Element +>TestMod : any +>Test : any + + diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution12.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution12.tsx new file mode 100644 index 00000000000..a9be0aad7b9 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution12.tsx @@ -0,0 +1,46 @@ +//@jsx: preserve + +//@filename: react.d.ts +declare module JSX { + interface Element { } + interface IntrinsicElements { + } + interface ElementAttributesProperty { + props; + } + interface IntrinsicAttributes { + ref?: string; + } +} + +//@filename: file.tsx + +declare class Component { + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; +} + + +interface ComponentClass

{ + new (props?: P, context?: any): Component; +} + +declare module TestMod { + interface TestClass extends ComponentClass<{reqd: any}> { + } + var Test: TestClass; +} + +// Errors correctly +const T = TestMod.Test; +var t1 = ; + +// Should error +var t2 = ; +