diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18d3232229..f7249a079f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11058,8 +11058,18 @@ namespace ts { } else { const constraintDeclaration = getConstraintDeclaration(typeParameter); - typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : - getInferredTypeParameterConstraint(typeParameter) || noConstraintType; + if (!constraintDeclaration) { + typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType; + } + else { + let type = getTypeFromTypeNode(constraintDeclaration); + if (type.flags & TypeFlags.Any && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed + // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), + // use unknown otherwise + type = constraintDeclaration.parent.parent.kind === SyntaxKind.MappedType ? keyofConstraintType : unknownType; + } + typeParameter.constraint = type; + } } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; diff --git a/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types b/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types index 7be0d89aed..7a70ab3c60 100644 --- a/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types +++ b/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types @@ -162,7 +162,7 @@ declare function g1(x: T): T; >x : T declare function g2(x: T): T; ->g2 : (x: T) => T +>g2 : (x: T) => T >x : T declare function g3(x: T): T; @@ -192,7 +192,7 @@ g1((x = 1) => 0); // number g2((x = 1) => 0); // number >g2((x = 1) => 0) : (x?: number) => 0 ->g2 : (x: T) => T +>g2 : (x: T) => T >(x = 1) => 0 : (x?: number) => 0 >x : number >1 : 1 diff --git a/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt b/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt new file mode 100644 index 0000000000..d2acf84824 --- /dev/null +++ b/tests/baselines/reference/jsxExcessPropsAndAssignability.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/jsxExcessPropsAndAssignability.tsx(16,6): error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Readonly<{ children?: ReactNode; }> & Readonly'. + Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'Readonly'. + + +==== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx (1 errors) ==== + /// + + import * as React from 'react'; + + const myHoc = ( + ComposedComponent: React.ComponentClass, + ) => { + type WrapperComponentProps = ComposedComponentProps & { myProp: string }; + const WrapperComponent: React.ComponentClass = null as any; + + const props: ComposedComponentProps = null as any; + + // Expected no error, got none - good + ; + // Expected error, but got none - bad! + ; + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Readonly<{ children?: ReactNode; }> & Readonly'. +!!! error TS2322: Type 'ComposedComponentProps & { myProp: number; }' is not assignable to type 'Readonly'. + }; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxExcessPropsAndAssignability.js b/tests/baselines/reference/jsxExcessPropsAndAssignability.js new file mode 100644 index 0000000000..68e02b9187 --- /dev/null +++ b/tests/baselines/reference/jsxExcessPropsAndAssignability.js @@ -0,0 +1,44 @@ +//// [jsxExcessPropsAndAssignability.tsx] +/// + +import * as React from 'react'; + +const myHoc = ( + ComposedComponent: React.ComponentClass, +) => { + type WrapperComponentProps = ComposedComponentProps & { myProp: string }; + const WrapperComponent: React.ComponentClass = null as any; + + const props: ComposedComponentProps = null as any; + + // Expected no error, got none - good + ; + // Expected error, but got none - bad! + ; +}; + + +//// [jsxExcessPropsAndAssignability.js] +"use strict"; +/// +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +exports.__esModule = true; +var React = require("react"); +var myHoc = function (ComposedComponent) { + var WrapperComponent = null; + var props = null; + // Expected no error, got none - good + React.createElement(WrapperComponent, __assign({}, props, { myProp: '1000000' })); + // Expected error, but got none - bad! + React.createElement(WrapperComponent, __assign({}, props, { myProp: 1000000 })); +}; diff --git a/tests/baselines/reference/jsxExcessPropsAndAssignability.symbols b/tests/baselines/reference/jsxExcessPropsAndAssignability.symbols new file mode 100644 index 0000000000..fa5e712abe --- /dev/null +++ b/tests/baselines/reference/jsxExcessPropsAndAssignability.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx === +/// + +import * as React from 'react'; +>React : Symbol(React, Decl(jsxExcessPropsAndAssignability.tsx, 2, 6)) + +const myHoc = ( +>myHoc : Symbol(myHoc, Decl(jsxExcessPropsAndAssignability.tsx, 4, 5)) +>ComposedComponentProps : Symbol(ComposedComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 4, 15)) + + ComposedComponent: React.ComponentClass, +>ComposedComponent : Symbol(ComposedComponent, Decl(jsxExcessPropsAndAssignability.tsx, 4, 51)) +>React : Symbol(React, Decl(jsxExcessPropsAndAssignability.tsx, 2, 6)) +>ComponentClass : Symbol(React.ComponentClass, Decl(react16.d.ts, 421, 9)) +>ComposedComponentProps : Symbol(ComposedComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 4, 15)) + +) => { + type WrapperComponentProps = ComposedComponentProps & { myProp: string }; +>WrapperComponentProps : Symbol(WrapperComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 6, 6)) +>ComposedComponentProps : Symbol(ComposedComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 4, 15)) +>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 7, 59)) + + const WrapperComponent: React.ComponentClass = null as any; +>WrapperComponent : Symbol(WrapperComponent, Decl(jsxExcessPropsAndAssignability.tsx, 8, 9)) +>React : Symbol(React, Decl(jsxExcessPropsAndAssignability.tsx, 2, 6)) +>ComponentClass : Symbol(React.ComponentClass, Decl(react16.d.ts, 421, 9)) +>WrapperComponentProps : Symbol(WrapperComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 6, 6)) + + const props: ComposedComponentProps = null as any; +>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9)) +>ComposedComponentProps : Symbol(ComposedComponentProps, Decl(jsxExcessPropsAndAssignability.tsx, 4, 15)) + + // Expected no error, got none - good + ; +>WrapperComponent : Symbol(WrapperComponent, Decl(jsxExcessPropsAndAssignability.tsx, 8, 9)) +>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9)) +>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 13, 32)) + + // Expected error, but got none - bad! + ; +>WrapperComponent : Symbol(WrapperComponent, Decl(jsxExcessPropsAndAssignability.tsx, 8, 9)) +>props : Symbol(props, Decl(jsxExcessPropsAndAssignability.tsx, 10, 9)) +>myProp : Symbol(myProp, Decl(jsxExcessPropsAndAssignability.tsx, 15, 32)) + +}; + diff --git a/tests/baselines/reference/jsxExcessPropsAndAssignability.types b/tests/baselines/reference/jsxExcessPropsAndAssignability.types new file mode 100644 index 0000000000..c9fa90a0c6 --- /dev/null +++ b/tests/baselines/reference/jsxExcessPropsAndAssignability.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/jsxExcessPropsAndAssignability.tsx === +/// + +import * as React from 'react'; +>React : typeof React + +const myHoc = ( +>myHoc : (ComposedComponent: React.ComponentClass) => void +>( ComposedComponent: React.ComponentClass,) => { type WrapperComponentProps = ComposedComponentProps & { myProp: string }; const WrapperComponent: React.ComponentClass = null as any; const props: ComposedComponentProps = null as any; // Expected no error, got none - good ; // Expected error, but got none - bad! ;} : (ComposedComponent: React.ComponentClass) => void + + ComposedComponent: React.ComponentClass, +>ComposedComponent : React.ComponentClass +>React : any + +) => { + type WrapperComponentProps = ComposedComponentProps & { myProp: string }; +>WrapperComponentProps : ComposedComponentProps & { myProp: string; } +>myProp : string + + const WrapperComponent: React.ComponentClass = null as any; +>WrapperComponent : React.ComponentClass +>React : any +>null as any : any +>null : null + + const props: ComposedComponentProps = null as any; +>props : ComposedComponentProps +>null as any : any +>null : null + + // Expected no error, got none - good + ; +> : JSX.Element +>WrapperComponent : React.ComponentClass +>props : ComposedComponentProps +>myProp : "1000000" +>'1000000' : "1000000" + + // Expected error, but got none - bad! + ; +> : JSX.Element +>WrapperComponent : React.ComponentClass +>props : ComposedComponentProps +>myProp : number +>1000000 : 1000000 + +}; + diff --git a/tests/baselines/reference/mappedTypeWithAny.types b/tests/baselines/reference/mappedTypeWithAny.types index 12690a6b95..6aa71ef174 100644 --- a/tests/baselines/reference/mappedTypeWithAny.types +++ b/tests/baselines/reference/mappedTypeWithAny.types @@ -10,7 +10,7 @@ declare let x0: keyof any; >x0 : string | number | symbol declare let x1: { [P in any]: Item }; ->x1 : { [x: string]: Item; } +>x1 : { [x: string]: Item; [x: number]: Item; } declare let x2: { [P in string]: Item }; >x2 : { [x: string]: Item; } diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.types b/tests/baselines/reference/typeArgumentInferenceWithConstraints.types index acc4bca0a2..332d463ad7 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.types +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.types @@ -357,7 +357,7 @@ x(null, null, null); // Error // Generic call with multiple parameters of generic type passed arguments with no best common type function someGenerics9(a: T, b: T, c: T): T { ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >a : T >b : T >c : T @@ -368,7 +368,7 @@ function someGenerics9(a: T, b: T, c: T): T { var a9a = someGenerics9('', 0, []); >a9a : string >someGenerics9('', 0, []) : "" ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >'' : "" >0 : 0 >[] : undefined[] @@ -379,7 +379,7 @@ var a9a: {}; var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); >a9b : { a?: number; b?: string; } >someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null) : { a?: number; b?: string; } ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >a : number >b : string >{ a: 0 } : { a: number; } @@ -413,7 +413,7 @@ interface A92 { var a9e = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); >a9e : { x: number; z: Window & typeof globalThis; y?: undefined; } | { x: number; y: string; z?: undefined; } >someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }) : { x: number; z: Window & typeof globalThis; y?: undefined; } | { x: number; y: string; z?: undefined; } ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >undefined : undefined >{ x: 6, z: window } : { x: number; z: Window & typeof globalThis; } >x : number @@ -432,7 +432,7 @@ var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); >a9f : A92 >someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }) : A92 ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >undefined : undefined >{ x: 6, z: window } : { x: number; z: Window & typeof globalThis; } >x : number @@ -452,7 +452,7 @@ var a9f: A92; var a9d = someGenerics9({ x: 3 }, { x: 6 }, { x: 6 }); >a9d : { x: number; } >someGenerics9({ x: 3 }, { x: 6 }, { x: 6 }) : { x: number; } ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >{ x: 3 } : { x: number; } >x : number >3 : 3 @@ -474,7 +474,7 @@ var anyVar: any; var a = someGenerics9(7, anyVar, 4); >a : any >someGenerics9(7, anyVar, 4) : any ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >7 : 7 >anyVar : any >4 : 4 @@ -486,7 +486,7 @@ var a: any; var arr = someGenerics9([], null, undefined); >arr : any[] >someGenerics9([], null, undefined) : any[] ->someGenerics9 : (a: T, b: T, c: T) => T +>someGenerics9 : (a: T, b: T, c: T) => T >[] : undefined[] >null : null >undefined : undefined diff --git a/tests/baselines/reference/typeParameterConstraints1.types b/tests/baselines/reference/typeParameterConstraints1.types index 204130d7df..f11407fe20 100644 --- a/tests/baselines/reference/typeParameterConstraints1.types +++ b/tests/baselines/reference/typeParameterConstraints1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/typeParameterConstraints1.ts === function foo1(test: T) { } ->foo1 : (test: T) => void +>foo1 : (test: T) => void >test : T function foo2(test: T) { } diff --git a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt index 27d1738fcb..07d7cee05f 100644 --- a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt +++ b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.errors.txt @@ -1,7 +1,14 @@ tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(3,7): error TS2339: Property 'blah' does not exist on type 'T'. +tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(9,7): error TS2339: Property 'blah' does not exist on type 'T'. +tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(14,7): error TS2339: Property 'children' does not exist on type 'T'. +tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(15,5): error TS2349: This expression is not callable. + Type '{}' has no call signatures. +tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(16,9): error TS2351: This expression is not constructable. + Type '{}' has no construct signatures. +tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(30,14): error TS2339: Property 'children' does not exist on type 'T'. -==== tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts (1 errors) ==== +==== tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts (6 errors) ==== function fee() { var t: T; t.blah; // Error @@ -13,13 +20,23 @@ tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(3,7): error TS2339: Pr function fee2() { var t: T; t.blah; // ok + ~~~~ +!!! error TS2339: Property 'blah' does not exist on type 'T'. t.toString; // ok } function f(x: T) { x.children; + ~~~~~~~~ +!!! error TS2339: Property 'children' does not exist on type 'T'. x(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type '{}' has no call signatures. new x(); + ~ +!!! error TS2351: This expression is not constructable. +!!! error TS2351: Type '{}' has no construct signatures. x[100]; x['hello']; } @@ -34,6 +51,8 @@ tests/cases/compiler/typeParameterExplicitlyExtendsAny.ts(3,7): error TS2339: Pr public static displayTree1>(tree: T) { // error "Property 'children' does not exist on type 'T'" tree.children; + ~~~~~~~~ +!!! error TS2339: Property 'children' does not exist on type 'T'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.symbols b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.symbols index 96ea15df17..5ff99f4c4d 100644 --- a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.symbols +++ b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.symbols @@ -28,7 +28,9 @@ function fee2() { >t : Symbol(t, Decl(typeParameterExplicitlyExtendsAny.ts, 7, 7)) t.toString; // ok +>t.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --)) >t : Symbol(t, Decl(typeParameterExplicitlyExtendsAny.ts, 7, 7)) +>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --)) } function f(x: T) { diff --git a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.types b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.types index 9b93cf02d4..788d45cd5a 100644 --- a/tests/baselines/reference/typeParameterExplicitlyExtendsAny.types +++ b/tests/baselines/reference/typeParameterExplicitlyExtendsAny.types @@ -17,7 +17,7 @@ function fee() { } function fee2() { ->fee2 : () => void +>fee2 : () => void var t: T; >t : T @@ -28,13 +28,13 @@ function fee2() { >blah : any t.toString; // ok ->t.toString : any +>t.toString : () => string >t : T ->toString : any +>toString : () => string } function f(x: T) { ->f : (x: T) => void +>f : (x: T) => void >x : T x.children; @@ -74,7 +74,7 @@ class MyClass { >MyClass : MyClass public static displayTree1>(tree: T) { ->displayTree1 : (tree: T) => void +>displayTree1 : (tree: T) => void >tree : T // error "Property 'children' does not exist on type 'T'" diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js index d53201295b..91fdb7d3e1 100644 --- a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js @@ -50,7 +50,7 @@ interface Any extends Type {} type TypeOf = C["_A"]; -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; type ToA = { [k in keyof S]: Type }; type NeededInfo = { diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols index bd97928406..ce297b87bb 100644 --- a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols @@ -184,17 +184,19 @@ type TypeOf = C["_A"]; >Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 45, 1)) >C : Symbol(C, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 49, 12)) -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; >ToB : Symbol(ToB, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 49, 37)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 9)) ->k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 29)) +>_ : Symbol(_, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 21)) +>Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 45, 1)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 64)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 9)) >TypeOf : Symbol(TypeOf, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 47, 44)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 9)) ->k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 29)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 64)) type ToA = { [k in keyof S]: Type }; ->ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 59)) +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 94)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 9)) >k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 17)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 9)) @@ -208,7 +210,7 @@ type NeededInfo = { ASchema: ToA; >ASchema : Symbol(ASchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 54, 43)) ->ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 59)) +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 94)) >MyNamespaceSchema : Symbol(MyNamespaceSchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 54, 16)) }; diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types index f6342d442e..fb92aa0dea 100644 --- a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types @@ -127,7 +127,7 @@ interface Any extends Type {} type TypeOf = C["_A"]; >TypeOf : C["_A"] -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; >ToB : ToB type ToA = { [k in keyof S]: Type }; diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js index ea11b03fcb..0b39a6176e 100644 --- a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js @@ -50,7 +50,7 @@ interface Any extends Type {} type TypeOf = C["_A"]; -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; type ToA = { [k in keyof S]: Type }; type NeededInfo = { diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols index 6d8983bd95..8680b44cc1 100644 --- a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols @@ -184,17 +184,19 @@ type TypeOf = C["_A"]; >Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 45, 1)) >C : Symbol(C, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 49, 12)) -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; >ToB : Symbol(ToB, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 49, 37)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 9)) ->k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 29)) +>_ : Symbol(_, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 21)) +>Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 45, 1)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 64)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 9)) >TypeOf : Symbol(TypeOf, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 47, 44)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 9)) ->k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 29)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 64)) type ToA = { [k in keyof S]: Type }; ->ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 59)) +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 94)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 9)) >k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 17)) >S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 9)) @@ -208,7 +210,7 @@ type NeededInfo = { ASchema: ToA; >ASchema : Symbol(ASchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 54, 43)) ->ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 59)) +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 94)) >MyNamespaceSchema : Symbol(MyNamespaceSchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 54, 16)) }; diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types index 02a69f2fab..73f1d4b720 100644 --- a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types @@ -127,7 +127,7 @@ interface Any extends Type {} type TypeOf = C["_A"]; >TypeOf : C["_A"] -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; >ToB : ToB type ToA = { [k in keyof S]: Type }; diff --git a/tests/cases/compiler/jsxExcessPropsAndAssignability.tsx b/tests/cases/compiler/jsxExcessPropsAndAssignability.tsx new file mode 100644 index 0000000000..e2437360ed --- /dev/null +++ b/tests/cases/compiler/jsxExcessPropsAndAssignability.tsx @@ -0,0 +1,19 @@ +// @jsx: react +// @strict: true +/// + +import * as React from 'react'; + +const myHoc = ( + ComposedComponent: React.ComponentClass, +) => { + type WrapperComponentProps = ComposedComponentProps & { myProp: string }; + const WrapperComponent: React.ComponentClass = null as any; + + const props: ComposedComponentProps = null as any; + + // Expected no error, got none - good + ; + // Expected error, but got none - bad! + ; +}; diff --git a/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts index c84abda5e5..0e0e2e4ce7 100644 --- a/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts +++ b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts @@ -50,7 +50,7 @@ interface Any extends Type {} type TypeOf = C["_A"]; -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; type ToA = { [k in keyof S]: Type }; type NeededInfo = { diff --git a/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts index 14d835e618..6d5f60ff09 100644 --- a/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts +++ b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts @@ -50,7 +50,7 @@ interface Any extends Type {} type TypeOf = C["_A"]; -type ToB = { [k in keyof S]: TypeOf }; +type ToB = { [k in keyof S]: TypeOf }; type ToA = { [k in keyof S]: Type }; type NeededInfo = {