mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fixes #35735: Avoids listing missing properties for types with only call/construct signatures (#40973)
* Fixes #35735 * fixes #35735 * PR feedback Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
This commit is contained in:
co-authored by
Wesley Wigham
parent
5f9f9e3752
commit
ae62da9413
+15
-1
@@ -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));
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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; }'.
|
||||
|
||||
@@ -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; }'.
|
||||
|
||||
+15
@@ -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;
|
||||
+16
@@ -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;
|
||||
+18
@@ -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;
|
||||
+15
@@ -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;
|
||||
@@ -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} */
|
||||
|
||||
+2
-3
@@ -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'.
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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))
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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 = <i1> anyVar;
|
||||
var obj9: i1 = new <i1> 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 = <i5> anyVar;
|
||||
var obj53: i5 = new <i5> anyVar;
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
interface Dog {
|
||||
barkable: true
|
||||
}
|
||||
|
||||
declare function getRover(): Dog
|
||||
|
||||
export let x:Dog = getRover;
|
||||
// export let x: Dog = getRover;
|
||||
@@ -0,0 +1,5 @@
|
||||
declare let x: { (): string; prop: number };
|
||||
declare let y: { (): string; }
|
||||
|
||||
x = y;
|
||||
y = x;
|
||||
Reference in New Issue
Block a user