diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9dfb4a7e112c2..a069896070217 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19996,7 +19996,7 @@ namespace ts { const requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); const unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false); if (unmatchedProperty) { - if (reportErrors) { + if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } return Ternary.False; @@ -20154,6 +20154,20 @@ namespace ts { return result; } + function shouldReportUnmatchedPropertyError(source: Type, target: Type): boolean { + const typeCallSignatures = getSignaturesOfStructuredType(source, SignatureKind.Call); + const typeConstructSignatures = getSignaturesOfStructuredType(source, SignatureKind.Construct); + const typeProperties = getPropertiesOfObjectType(source); + if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { + if ((getSignaturesOfType(target, SignatureKind.Call).length && typeCallSignatures.length) || + (getSignaturesOfType(target, SignatureKind.Construct).length && typeConstructSignatures.length)) { + return true; // target has similar signature kinds to source, still focus on the unmatched property + } + return false; + } + return true; + } + function reportIncompatibleCallSignatureReturn(siga: Signature, sigb: Signature) { if (siga.parameters.length === 0 && sigb.parameters.length === 0) { return (source: Type, target: Type) => reportIncompatibleError(Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); diff --git a/tests/baselines/reference/arrayAssignmentTest1.errors.txt b/tests/baselines/reference/arrayAssignmentTest1.errors.txt index 4ee34fcf7368e..2ff2066dac365 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest1.errors.txt @@ -20,7 +20,7 @@ tests/cases/compiler/arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is Property 'CM3M1' is missing in type 'C1' but required in type 'C3'. tests/cases/compiler/arrayAssignmentTest1.ts(77,1): error TS2322: Type 'I1[]' is not assignable to type 'C3[]'. Property 'CM3M1' is missing in type 'I1' but required in type 'C3'. -tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2740: Type '() => C1' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'. tests/cases/compiler/arrayAssignmentTest1.ts(80,1): error TS2740: Type '{ one: number; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. tests/cases/compiler/arrayAssignmentTest1.ts(82,1): error TS2740: Type 'C1' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. tests/cases/compiler/arrayAssignmentTest1.ts(83,1): error TS2740: Type 'C2' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. @@ -152,7 +152,7 @@ tests/cases/compiler/arrayAssignmentTest1.ts(85,1): error TS2740: Type 'I1' is m arr_any = f1; // should be an error - is ~~~~~~~ -!!! error TS2740: Type '() => C1' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +!!! error TS2322: Type '() => C1' is not assignable to type 'any[]'. arr_any = o1; // should be an error - is ~~~~~~~ !!! error TS2740: Type '{ one: number; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. diff --git a/tests/baselines/reference/arrayAssignmentTest2.errors.txt b/tests/baselines/reference/arrayAssignmentTest2.errors.txt index 4333dd119d666..f79695c546ce1 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest2.errors.txt @@ -4,8 +4,8 @@ tests/cases/compiler/arrayAssignmentTest2.ts(48,1): error TS2322: Type 'C1[]' is Property 'CM3M1' is missing in type 'C1' but required in type 'C3'. tests/cases/compiler/arrayAssignmentTest2.ts(49,1): error TS2322: Type 'I1[]' is not assignable to type 'C3[]'. Property 'CM3M1' is missing in type 'I1' but required in type 'C3'. -tests/cases/compiler/arrayAssignmentTest2.ts(51,1): error TS2740: Type '() => C1' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. -tests/cases/compiler/arrayAssignmentTest2.ts(52,1): error TS2740: Type '() => any' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +tests/cases/compiler/arrayAssignmentTest2.ts(51,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'. +tests/cases/compiler/arrayAssignmentTest2.ts(52,1): error TS2322: Type '() => any' is not assignable to type 'any[]'. tests/cases/compiler/arrayAssignmentTest2.ts(53,1): error TS2740: Type '{ one: number; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. tests/cases/compiler/arrayAssignmentTest2.ts(55,1): error TS2740: Type 'C1' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. tests/cases/compiler/arrayAssignmentTest2.ts(56,1): error TS2740: Type 'C2' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. @@ -78,10 +78,10 @@ tests/cases/compiler/arrayAssignmentTest2.ts(58,1): error TS2740: Type 'I1' is m arr_any = f1; // should be an error - is ~~~~~~~ -!!! error TS2740: Type '() => C1' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +!!! error TS2322: Type '() => C1' is not assignable to type 'any[]'. arr_any = function () { return null;} // should be an error - is ~~~~~~~ -!!! error TS2740: Type '() => any' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +!!! error TS2322: Type '() => any' is not assignable to type 'any[]'. arr_any = o1; // should be an error - is ~~~~~~~ !!! error TS2740: Type '{ one: number; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. diff --git a/tests/baselines/reference/arrayAssignmentTest4.errors.txt b/tests/baselines/reference/arrayAssignmentTest4.errors.txt index 3e1c6c3de1285..c2103507d902a 100644 --- a/tests/baselines/reference/arrayAssignmentTest4.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/arrayAssignmentTest4.ts(22,1): error TS2740: Type '() => any' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +tests/cases/compiler/arrayAssignmentTest4.ts(22,1): error TS2322: Type '() => any' is not assignable to type 'any[]'. tests/cases/compiler/arrayAssignmentTest4.ts(23,1): error TS2740: Type 'C3' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. @@ -26,7 +26,7 @@ tests/cases/compiler/arrayAssignmentTest4.ts(23,1): error TS2740: Type 'C3' is m arr_any = function () { return null;} // should be an error - is ~~~~~~~ -!!! error TS2740: Type '() => any' is missing the following properties from type 'any[]': pop, push, concat, join, and 15 more. +!!! error TS2322: Type '() => any' is not assignable to type 'any[]'. arr_any = c3; // should be an error - is ~~~~~~~ !!! error TS2740: Type 'C3' is missing the following properties from type 'any[]': length, pop, push, concat, and 16 more. diff --git a/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.errors.txt b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.errors.txt index eeab9734ccdbb..4f0e5d0d7be41 100644 --- a/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.errors.txt +++ b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts(7,4): error TS2345: Argument of type '(a: any, b: any) => boolean' is not assignable to parameter of type 'IResultCallback'. - Property 'x' is missing in type '(a: any, b: any) => boolean' but required in type 'IResultCallback'. tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts(8,4): error TS2345: Argument of type '(a: any, b: any) => boolean' is not assignable to parameter of type 'IResultCallback'. - Property 'x' is missing in type '(a: any, b: any) => boolean' but required in type 'IResultCallback'. ==== tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts (2 errors) ==== @@ -14,11 +12,7 @@ tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts(8,4): error TS234 fn((a, b) => true); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(a: any, b: any) => boolean' is not assignable to parameter of type 'IResultCallback'. -!!! error TS2345: Property 'x' is missing in type '(a: any, b: any) => boolean' but required in type 'IResultCallback'. -!!! related TS2728 tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts:2:5: 'x' is declared here. fn(function (a, b) { return true; }) ~~~~~~~~ !!! error TS2345: Argument of type '(a: any, b: any) => boolean' is not assignable to parameter of type 'IResultCallback'. -!!! error TS2345: Property 'x' is missing in type '(a: any, b: any) => boolean' but required in type 'IResultCallback'. -!!! related TS2728 tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts:2:5: 'x' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures2.errors.txt index ba14424f99fee..12cd30864464f 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(31,1): error TS2741: Property 'f' is missing in type '() => number' but required in type 'T'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(32,1): error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type 'T'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(33,1): error TS2741: Property 'f' is missing in type '() => number' but required in type '{ f(x: number): void; }'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(34,1): error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type '{ f(x: number): void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(31,1): error TS2322: Type '() => number' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(32,1): error TS2322: Type '(x: number) => string' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(33,1): error TS2322: Type '() => number' is not assignable to type '{ f(x: number): void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(34,1): error TS2322: Type '(x: number) => string' is not assignable to type '{ f(x: number): void; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(42,1): error TS2322: Type 'S2' is not assignable to type 'T'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type '(x: number) => void'. @@ -12,8 +12,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '(x: string) => void' is not assignable to type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(44,1): error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type 'T'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(45,1): error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(44,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(45,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(46,1): error TS2322: Type 'S2' is not assignable to type '{ f(x: number): void; }'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type '(x: number) => void'. @@ -24,8 +24,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type '(x: string) => void' is not assignable to type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(48,1): error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type '{ f(x: number): void; }'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(49,1): error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type '{ f(x: number): void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(48,1): error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(49,1): error TS2322: Type '(x: string) => string' is not assignable to type '{ f(x: number): void; }'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts (12 errors) ==== @@ -61,20 +61,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme // errors t = () => 1; ~ -!!! error TS2741: Property 'f' is missing in type '() => number' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '() => number' is not assignable to type 'T'. t = function (x: number) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '(x: number) => string' is not assignable to type 'T'. a = () => 1; ~ -!!! error TS2741: Property 'f' is missing in type '() => number' but required in type '{ f(x: number): void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '() => number' is not assignable to type '{ f(x: number): void; }'. a = function (x: number) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type '{ f(x: number): void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '(x: number) => string' is not assignable to type '{ f(x: number): void; }'. interface S2 { f(x: string): void; @@ -98,12 +94,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'number' is not assignable to type 'string'. t = (x: string) => 1; ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'. t = function (x: string) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'. a = s2; ~ !!! error TS2322: Type 'S2' is not assignable to type '{ f(x: number): void; }'. @@ -120,10 +114,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'number' is not assignable to type 'string'. a = (x: string) => 1; ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type '{ f(x: number): void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'. a = function (x: string) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type '{ f(x: number): void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '(x: string) => string' is not assignable to type '{ f(x: number): void; }'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt index b42670aa9022c..9491885cc81f5 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(23,1): error TS2741: Property 'f' is missing in type '() => number' but required in type 'T'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(24,1): error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type 'T'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(25,1): error TS2741: Property 'f' is missing in type '() => number' but required in type '{ f: new (x: number) => void; }'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(26,1): error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type '{ f: new (x: number) => void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(23,1): error TS2322: Type '() => number' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(24,1): error TS2322: Type '(x: number) => string' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(25,1): error TS2322: Type '() => number' is not assignable to type '{ f: new (x: number) => void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(26,1): error TS2322: Type '(x: number) => string' is not assignable to type '{ f: new (x: number) => void; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(34,1): error TS2322: Type 'S2' is not assignable to type 'T'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. @@ -10,8 +10,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. Type '(x: string) => void' provides no match for the signature 'new (x: number): void'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(36,1): error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type 'T'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(37,1): error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(36,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(37,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(38,1): error TS2322: Type 'S2' is not assignable to type '{ f: new (x: number) => void; }'. Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. @@ -20,8 +20,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Types of property 'f' are incompatible. Type '(x: string) => void' is not assignable to type 'new (x: number) => void'. Type '(x: string) => void' provides no match for the signature 'new (x: number): void'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(40,1): error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type '{ f: new (x: number) => void; }'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(41,1): error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type '{ f: new (x: number) => void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(40,1): error TS2322: Type '(x: string) => number' is not assignable to type '{ f: new (x: number) => void; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts(41,1): error TS2322: Type '(x: string) => string' is not assignable to type '{ f: new (x: number) => void; }'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts (12 errors) ==== @@ -49,20 +49,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme // errors t = () => 1; ~ -!!! error TS2741: Property 'f' is missing in type '() => number' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '() => number' is not assignable to type 'T'. t = function (x: number) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '(x: number) => string' is not assignable to type 'T'. a = () => 1; ~ -!!! error TS2741: Property 'f' is missing in type '() => number' but required in type '{ f: new (x: number) => void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '() => number' is not assignable to type '{ f: new (x: number) => void; }'. a = function (x: number) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: number) => string' but required in type '{ f: new (x: number) => void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '(x: number) => string' is not assignable to type '{ f: new (x: number) => void; }'. interface S2 { f(x: string): void; @@ -84,12 +80,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'. t = (x: string) => 1; ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'. t = function (x: string) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type 'T'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:4:5: 'f' is declared here. +!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'. a = s2; ~ !!! error TS2322: Type 'S2' is not assignable to type '{ f: new (x: number) => void; }'. @@ -104,10 +98,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type '(x: string) => void' provides no match for the signature 'new (x: number): void'. a = (x: string) => 1; ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => number' but required in type '{ f: new (x: number) => void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f: new (x: number) => void; }'. a = function (x: string) { return ''; } ~ -!!! error TS2741: Property 'f' is missing in type '(x: string) => string' but required in type '{ f: new (x: number) => void; }'. -!!! related TS2728 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts:7:10: 'f' is declared here. +!!! error TS2322: Type '(x: string) => string' is not assignable to type '{ f: new (x: number) => void; }'. \ No newline at end of file diff --git a/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.errors.txt b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.errors.txt new file mode 100644 index 0000000000000..444fe284b26c7 --- /dev/null +++ b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts(7,20): error TS2322: Type '() => Dog' is not assignable to type 'Dog'. + + +==== tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts (1 errors) ==== + interface Dog { + barkable: true + } + + declare function getRover(): Dog + + export let x:Dog = getRover; + ~~~~~~~~ +!!! error TS2322: Type '() => Dog' is not assignable to type 'Dog'. +!!! related TS6212 tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts:7:20: Did you mean to call this expression? + // export let x: Dog = getRover; \ No newline at end of file diff --git a/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.js b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.js new file mode 100644 index 0000000000000..8607be93b3086 --- /dev/null +++ b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.js @@ -0,0 +1,16 @@ +//// [avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts] +interface Dog { + barkable: true +} + +declare function getRover(): Dog + +export let x:Dog = getRover; +// export let x: Dog = getRover; + +//// [avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.js] +"use strict"; +exports.__esModule = true; +exports.x = void 0; +exports.x = getRover; +// export let x: Dog = getRover; diff --git a/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.symbols b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.symbols new file mode 100644 index 0000000000000..2f6116fe78de9 --- /dev/null +++ b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts === +interface Dog { +>Dog : Symbol(Dog, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 0, 0)) + + barkable: true +>barkable : Symbol(Dog.barkable, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 0, 15)) +} + +declare function getRover(): Dog +>getRover : Symbol(getRover, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 2, 1)) +>Dog : Symbol(Dog, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 0, 0)) + +export let x:Dog = getRover; +>x : Symbol(x, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 6, 10)) +>Dog : Symbol(Dog, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 0, 0)) +>getRover : Symbol(getRover, Decl(avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts, 2, 1)) + +// export let x: Dog = getRover; diff --git a/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.types b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.types new file mode 100644 index 0000000000000..c3c7b18a67d82 --- /dev/null +++ b/tests/baselines/reference/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts === +interface Dog { + barkable: true +>barkable : true +>true : true +} + +declare function getRover(): Dog +>getRover : () => Dog + +export let x:Dog = getRover; +>x : Dog +>getRover : () => Dog + +// export let x: Dog = getRover; diff --git a/tests/baselines/reference/checkJsdocTypeTag6.errors.txt b/tests/baselines/reference/checkJsdocTypeTag6.errors.txt index 7a7915c0f618c..1106e60da7502 100644 --- a/tests/baselines/reference/checkJsdocTypeTag6.errors.txt +++ b/tests/baselines/reference/checkJsdocTypeTag6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/jsdoc/test.js(1,12): error TS8030: The type of a function declaration must match the function's signature. -tests/cases/conformance/jsdoc/test.js(7,5): error TS2741: Property 'prop' is missing in type '(prop: any) => void' but required in type '{ prop: string; }'. +tests/cases/conformance/jsdoc/test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. tests/cases/conformance/jsdoc/test.js(10,12): error TS8030: The type of a function declaration must match the function's signature. @@ -14,8 +14,7 @@ tests/cases/conformance/jsdoc/test.js(10,12): error TS8030: The type of a functi /** @type {{ prop: string }} */ var g = function (prop) { ~ -!!! error TS2741: Property 'prop' is missing in type '(prop: any) => void' but required in type '{ prop: string; }'. -!!! related TS2728 tests/cases/conformance/jsdoc/test.js:6:14: 'prop' is declared here. +!!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. } /** @type {(a: number) => number} */ diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt index 40deaf591d8f1..fa0f473af76a8 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts(9,5): error TS2741: Property 'x' is missing in type '(x: "hi", items: string[]) => typeof foo' but required in type 'C'. +tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts(9,5): error TS2322: Type '(x: "hi", items: string[]) => typeof foo' is not assignable to type 'D'. ==== tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts (1 errors) ==== @@ -12,6 +12,5 @@ tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts(9,5): e } var a: D = foo("hi", []); ~ -!!! error TS2741: Property 'x' is missing in type '(x: "hi", items: string[]) => typeof foo' but required in type 'C'. -!!! related TS2728 tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts:2:13: 'x' is declared here. +!!! error TS2322: Type '(x: "hi", items: string[]) => typeof foo' is not assignable to type 'D'. \ No newline at end of file diff --git a/tests/baselines/reference/functionToFunctionWithPropError.errors.txt b/tests/baselines/reference/functionToFunctionWithPropError.errors.txt new file mode 100644 index 0000000000000..627616afe2c7b --- /dev/null +++ b/tests/baselines/reference/functionToFunctionWithPropError.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/functionToFunctionWithPropError.ts(4,1): error TS2741: Property 'prop' is missing in type '() => string' but required in type '{ (): string; prop: number; }'. + + +==== tests/cases/compiler/functionToFunctionWithPropError.ts (1 errors) ==== + declare let x: { (): string; prop: number }; + declare let y: { (): string; } + + x = y; + ~ +!!! error TS2741: Property 'prop' is missing in type '() => string' but required in type '{ (): string; prop: number; }'. +!!! related TS2728 tests/cases/compiler/functionToFunctionWithPropError.ts:1:30: 'prop' is declared here. + y = x; \ No newline at end of file diff --git a/tests/baselines/reference/functionToFunctionWithPropError.js b/tests/baselines/reference/functionToFunctionWithPropError.js new file mode 100644 index 0000000000000..e1727897b9bbf --- /dev/null +++ b/tests/baselines/reference/functionToFunctionWithPropError.js @@ -0,0 +1,10 @@ +//// [functionToFunctionWithPropError.ts] +declare let x: { (): string; prop: number }; +declare let y: { (): string; } + +x = y; +y = x; + +//// [functionToFunctionWithPropError.js] +x = y; +y = x; diff --git a/tests/baselines/reference/functionToFunctionWithPropError.symbols b/tests/baselines/reference/functionToFunctionWithPropError.symbols new file mode 100644 index 0000000000000..0c204a678797c --- /dev/null +++ b/tests/baselines/reference/functionToFunctionWithPropError.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/functionToFunctionWithPropError.ts === +declare let x: { (): string; prop: number }; +>x : Symbol(x, Decl(functionToFunctionWithPropError.ts, 0, 11)) +>prop : Symbol(prop, Decl(functionToFunctionWithPropError.ts, 0, 28)) + +declare let y: { (): string; } +>y : Symbol(y, Decl(functionToFunctionWithPropError.ts, 1, 11)) + +x = y; +>x : Symbol(x, Decl(functionToFunctionWithPropError.ts, 0, 11)) +>y : Symbol(y, Decl(functionToFunctionWithPropError.ts, 1, 11)) + +y = x; +>y : Symbol(y, Decl(functionToFunctionWithPropError.ts, 1, 11)) +>x : Symbol(x, Decl(functionToFunctionWithPropError.ts, 0, 11)) + diff --git a/tests/baselines/reference/functionToFunctionWithPropError.types b/tests/baselines/reference/functionToFunctionWithPropError.types new file mode 100644 index 0000000000000..7351d9f3dafab --- /dev/null +++ b/tests/baselines/reference/functionToFunctionWithPropError.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/functionToFunctionWithPropError.ts === +declare let x: { (): string; prop: number }; +>x : { (): string; prop: number; } +>prop : number + +declare let y: { (): string; } +>y : () => string + +x = y; +>x = y : () => string +>x : { (): string; prop: number; } +>y : () => string + +y = x; +>y = x : { (): string; prop: number; } +>y : () => string +>x : { (): string; prop: number; } + diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index 2b4b8638cc953..7a4650de7d722 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/intTypeCheck.ts(99,5): error TS2696: The 'Object' type is a tests/cases/compiler/intTypeCheck.ts(100,20): error TS2351: This expression is not constructable. Type 'i1' has no construct signatures. tests/cases/compiler/intTypeCheck.ts(101,5): error TS2739: Type 'Base' is missing the following properties from type 'i1': p, p3, p6 -tests/cases/compiler/intTypeCheck.ts(103,5): error TS2739: Type '() => void' is missing the following properties from type 'i1': p, p3, p6 +tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is not assignable to type 'i1'. tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'. tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(106,21): error TS2693: 'i1' only refers to a type, but is being used as a value here. @@ -52,7 +52,7 @@ tests/cases/compiler/intTypeCheck.ts(155,5): error TS2696: The 'Object' type is tests/cases/compiler/intTypeCheck.ts(156,21): error TS2351: This expression is not constructable. Type 'i5' has no construct signatures. tests/cases/compiler/intTypeCheck.ts(157,5): error TS2739: Type 'Base' is missing the following properties from type 'i5': p, p3, p6 -tests/cases/compiler/intTypeCheck.ts(159,5): error TS2739: Type '() => void' is missing the following properties from type 'i5': p, p3, p6 +tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is not assignable to type 'i5'. tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'. tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(162,22): error TS2693: 'i5' only refers to a type, but is being used as a value here. @@ -215,7 +215,7 @@ tests/cases/compiler/intTypeCheck.ts(205,21): error TS2351: This expression is n var obj5: i1 = null; var obj6: i1 = function () { }; ~~~~ -!!! error TS2739: Type '() => void' is missing the following properties from type 'i1': p, p3, p6 +!!! error TS2322: Type '() => void' is not assignable to type 'i1'. //var obj7: i1 = function foo() { }; var obj8: i1 = anyVar; var obj9: i1 = new anyVar; @@ -347,7 +347,7 @@ tests/cases/compiler/intTypeCheck.ts(205,21): error TS2351: This expression is n var obj49: i5 = null; var obj50: i5 = function () { }; ~~~~~ -!!! error TS2739: Type '() => void' is missing the following properties from type 'i5': p, p3, p6 +!!! error TS2322: Type '() => void' is not assignable to type 'i5'. //var obj51: i5 = function foo() { }; var obj52: i5 = anyVar; var obj53: i5 = new anyVar; diff --git a/tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts b/tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts new file mode 100644 index 0000000000000..4bc72303fb0f5 --- /dev/null +++ b/tests/cases/compiler/avoidListingPropertiesForTypesWithOnlyCallOrConstructSignatures.ts @@ -0,0 +1,8 @@ +interface Dog { + barkable: true +} + +declare function getRover(): Dog + +export let x:Dog = getRover; +// export let x: Dog = getRover; \ No newline at end of file diff --git a/tests/cases/compiler/functionToFunctionWithPropError.ts b/tests/cases/compiler/functionToFunctionWithPropError.ts new file mode 100644 index 0000000000000..149a17a731447 --- /dev/null +++ b/tests/cases/compiler/functionToFunctionWithPropError.ts @@ -0,0 +1,5 @@ +declare let x: { (): string; prop: number }; +declare let y: { (): string; } + +x = y; +y = x; \ No newline at end of file