diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 1fa8c4360c..b6d46d2e70 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -2328,7 +2328,7 @@ func (c *Checker) checkDeferredNode(node *ast.Node) { c.checkJsxSelfClosingElementDeferred(node) case ast.KindJsxElement: c.checkJsxElementDeferred(node) - case ast.KindTypeAssertionExpression, ast.KindAsExpression, ast.KindParenthesizedExpression: + case ast.KindTypeAssertionExpression, ast.KindAsExpression: c.checkAssertionDeferred(node) case ast.KindVoidExpression: c.checkExpression(node.AsVoidExpression().Expression) @@ -11799,7 +11799,11 @@ func (c *Checker) checkAssertionDeferred(node *ast.Node) { if !c.isErrorType(targetType) { widenedType := c.getWidenedType(exprType) if !c.isTypeComparableTo(targetType, widenedType) { - c.checkTypeComparableTo(exprType, targetType, node, diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first) + errNode := node + if node.Flags&ast.NodeFlagsReparsed != 0 { + errNode = node.Type() + } + c.checkTypeComparableTo(exprType, targetType, errNode, diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first) } } } diff --git a/internal/checker/relater.go b/internal/checker/relater.go index 2219197356..e6315974d0 100644 --- a/internal/checker/relater.go +++ b/internal/checker/relater.go @@ -4728,16 +4728,16 @@ func (r *Relater) reportRelationError(message *diagnostics.Message, source *Type return } // Suppress if next message is a missing property message for source and target and we're not - // reporting on interface implementation + // reporting on conversion or interface implementation case diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2: - if !isInterfaceImplementationMessage(message) && r.chainArgsMatch(nil, generalizedSourceType, targetType) { + if !isConversionOrInterfaceImplementationMessage(message) && r.chainArgsMatch(nil, generalizedSourceType, targetType) { return } // Suppress if next message is a missing property message for source and target and we're not - // reporting on interface implementation + // reporting on conversion or interface implementation case diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2: - if !isInterfaceImplementationMessage(message) && r.chainArgsMatch(generalizedSourceType, targetType) { + if !isConversionOrInterfaceImplementationMessage(message) && r.chainArgsMatch(generalizedSourceType, targetType) { return } } @@ -4847,9 +4847,10 @@ func getPropertyNameArg(arg any) string { return s } -func isInterfaceImplementationMessage(message *diagnostics.Message) bool { +func isConversionOrInterfaceImplementationMessage(message *diagnostics.Message) bool { return message == diagnostics.Class_0_incorrectly_implements_interface_1 || - message == diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass + message == diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass || + message == diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first } func chainDepth(chain *ErrorChain) int { diff --git a/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt b/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt index 45eab58395..36e42284cd 100644 --- a/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt @@ -2,7 +2,8 @@ fuzzy.ts(13,18): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'alsoWorks' is missing in type 'C' but required in type 'I'. fuzzy.ts(21,34): error TS2322: Type 'this' is not assignable to type 'I'. Property 'alsoWorks' is missing in type 'C' but required in type 'I'. -fuzzy.ts(25,20): error TS2741: Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. +fuzzy.ts(25,20): error TS2352: Conversion of type '{ oneI: this; }' to type 'R' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. ==== fuzzy.ts (3 errors) ==== @@ -41,7 +42,8 @@ fuzzy.ts(25,20): error TS2741: Property 'anything' is missing in type '{ oneI: t worksToo():R { return ({ oneI: this }); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2741: Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. +!!! error TS2352: Conversion of type '{ oneI: this; }' to type 'R' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. !!! related TS2728 fuzzy.ts:9:9: 'anything' is declared here. } } diff --git a/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt.diff deleted file mode 100644 index 5facc6efa7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/fuzzy.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.fuzzy.errors.txt -+++ new.fuzzy.errors.txt -@@= skipped -1, +1 lines =@@ - Property 'alsoWorks' is missing in type 'C' but required in type 'I'. - fuzzy.ts(21,34): error TS2322: Type 'this' is not assignable to type 'I'. - Property 'alsoWorks' is missing in type 'C' but required in type 'I'. --fuzzy.ts(25,20): error TS2352: Conversion of type '{ oneI: this; }' to type 'R' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. -+fuzzy.ts(25,20): error TS2741: Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. - - - ==== fuzzy.ts (3 errors) ==== -@@= skipped -40, +39 lines =@@ - worksToo():R { - return ({ oneI: this }); - ~~~~~~~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type '{ oneI: this; }' to type 'R' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. -+!!! error TS2741: Property 'anything' is missing in type '{ oneI: this; }' but required in type 'R'. - !!! related TS2728 fuzzy.ts:9:9: 'anything' is declared here. - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt b/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt index 80d18cb9f7..8b6b4da09e 100644 --- a/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt @@ -4,7 +4,8 @@ genericTypeAssertions2.ts(10,5): error TS2322: Type 'B' is not assignabl Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. genericTypeAssertions2.ts(11,5): error TS2741: Property 'bar' is missing in type 'A' but required in type 'B'. -genericTypeAssertions2.ts(13,21): error TS2741: Property 'foo' is missing in type 'undefined[]' but required in type 'A'. +genericTypeAssertions2.ts(13,21): error TS2352: Conversion of type 'undefined[]' to type 'A' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'foo' is missing in type 'undefined[]' but required in type 'A'. ==== genericTypeAssertions2.ts (3 errors) ==== @@ -31,5 +32,6 @@ genericTypeAssertions2.ts(13,21): error TS2741: Property 'foo' is missing in typ var r4: A = >new A(); var r5: A = >[]; // error ~~~~~~~~~~~~~ -!!! error TS2741: Property 'foo' is missing in type 'undefined[]' but required in type 'A'. +!!! error TS2352: Conversion of type 'undefined[]' to type 'A' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'foo' is missing in type 'undefined[]' but required in type 'A'. !!! related TS2728 genericTypeAssertions2.ts:1:14: 'foo' is declared here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt.diff deleted file mode 100644 index 0365ab7e80..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericTypeAssertions2.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.genericTypeAssertions2.errors.txt -+++ new.genericTypeAssertions2.errors.txt -@@= skipped -3, +3 lines =@@ - Types of parameters 'x' and 'x' are incompatible. - Type 'number' is not assignable to type 'string'. - genericTypeAssertions2.ts(11,5): error TS2741: Property 'bar' is missing in type 'A' but required in type 'B'. --genericTypeAssertions2.ts(13,21): error TS2352: Conversion of type 'undefined[]' to type 'A' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'foo' is missing in type 'undefined[]' but required in type 'A'. -+genericTypeAssertions2.ts(13,21): error TS2741: Property 'foo' is missing in type 'undefined[]' but required in type 'A'. - - - ==== genericTypeAssertions2.ts (3 errors) ==== -@@= skipped -28, +27 lines =@@ - var r4: A = >new A(); - var r5: A = >[]; // error - ~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type 'undefined[]' to type 'A' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'foo' is missing in type 'undefined[]' but required in type 'A'. -+!!! error TS2741: Property 'foo' is missing in type 'undefined[]' but required in type 'A'. - !!! related TS2728 genericTypeAssertions2.ts:1:14: 'foo' is declared here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt index 64329bd677..16dfdd526f 100644 --- a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt @@ -1,4 +1,5 @@ -noImplicitAnyInCastExpression.ts(15,2): error TS2739: Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b +noImplicitAnyInCastExpression.ts(15,2): error TS2352: Conversion of type '{ c: null; }' to type 'IFoo' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b ==== noImplicitAnyInCastExpression.ts (1 errors) ==== @@ -18,4 +19,5 @@ noImplicitAnyInCastExpression.ts(15,2): error TS2739: Type '{ c: null; }' is mis // Neither types is assignable to each other ({ c: null }); ~~~~~~~~~~~~~~~~~ -!!! error TS2739: Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b \ No newline at end of file +!!! error TS2352: Conversion of type '{ c: null; }' to type 'IFoo' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt.diff deleted file mode 100644 index 08166d876d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.noImplicitAnyInCastExpression.errors.txt -+++ new.noImplicitAnyInCastExpression.errors.txt -@@= skipped -0, +0 lines =@@ --noImplicitAnyInCastExpression.ts(15,2): error TS2352: Conversion of type '{ c: null; }' to type 'IFoo' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b -+noImplicitAnyInCastExpression.ts(15,2): error TS2739: Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b - - - ==== noImplicitAnyInCastExpression.ts (1 errors) ==== -@@= skipped -18, +17 lines =@@ - // Neither types is assignable to each other - ({ c: null }); - ~~~~~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type '{ c: null; }' to type 'IFoo' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b -+!!! error TS2739: Type '{ c: null; }' is missing the following properties from type 'IFoo': a, b \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index 5ca40c9e5b..be6b9a3a2f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -1,8 +1,12 @@ -b.js(4,31): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -b.js(52,38): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. +b.js(4,20): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +b.js(45,23): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. +b.js(49,26): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +b.js(51,24): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. +b.js(52,24): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. b.js(67,2): error TS2322: Type 'string | number' is not assignable to type 'string'. @@ -18,7 +22,7 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. var W = /** @type {string} */(/** @type {*} */ (4)); var W = /** @type {string} */(4); // Error - ~ + ~~~~~~ !!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. /** @type {*} */ @@ -61,23 +65,27 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. someBase = /** @type {SomeBase} */(someDerived); someBase = /** @type {SomeBase} */(someBase); someBase = /** @type {SomeBase} */(someOther); // Error - ~~~~~~~~~ -!!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. + ~~~~~~~~ +!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. !!! related TS2728 b.js:17:9: 'p' is declared here. someDerived = /** @type {SomeDerived} */(someDerived); someDerived = /** @type {SomeDerived} */(someBase); someDerived = /** @type {SomeDerived} */(someOther); // Error - ~~~~~~~~~ -!!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x + ~~~~~~~~~~~ +!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x someOther = /** @type {SomeOther} */(someDerived); // Error - ~~~~~~~~~~~ -!!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. + ~~~~~~~~~ +!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someBase); // Error - ~~~~~~~~ -!!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. + ~~~~~~~~~ +!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someOther); diff --git a/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt b/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt index 0f71ae0619..34ae35538d 100644 --- a/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt @@ -1,4 +1,5 @@ -objectTypesIdentityWithPrivates3.ts(25,1): error TS2741: Property 'y' is missing in type 'C3' but required in type 'C4'. +objectTypesIdentityWithPrivates3.ts(25,1): error TS2352: Conversion of type 'C3' to type 'C4' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'y' is missing in type 'C3' but required in type 'C4'. ==== objectTypesIdentityWithPrivates3.ts (1 errors) ==== @@ -28,5 +29,6 @@ objectTypesIdentityWithPrivates3.ts(25,1): error TS2741: Property 'y' is missing var c3: C3; c3; // Should fail (private x originates in the same declaration, but different types) ~~~~~~ -!!! error TS2741: Property 'y' is missing in type 'C3' but required in type 'C4'. +!!! error TS2352: Conversion of type 'C3' to type 'C4' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'y' is missing in type 'C3' but required in type 'C4'. !!! related TS2728 objectTypesIdentityWithPrivates3.ts:21:5: 'y' is declared here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt.diff deleted file mode 100644 index e52f1c3786..0000000000 --- a/testdata/baselines/reference/submodule/conformance/objectTypesIdentityWithPrivates3.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.objectTypesIdentityWithPrivates3.errors.txt -+++ new.objectTypesIdentityWithPrivates3.errors.txt -@@= skipped -0, +0 lines =@@ --objectTypesIdentityWithPrivates3.ts(25,1): error TS2352: Conversion of type 'C3' to type 'C4' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'y' is missing in type 'C3' but required in type 'C4'. -+objectTypesIdentityWithPrivates3.ts(25,1): error TS2741: Property 'y' is missing in type 'C3' but required in type 'C4'. - - - ==== objectTypesIdentityWithPrivates3.ts (1 errors) ==== -@@= skipped -28, +27 lines =@@ - var c3: C3; - c3; // Should fail (private x originates in the same declaration, but different types) - ~~~~~~ --!!! error TS2352: Conversion of type 'C3' to type 'C4' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'y' is missing in type 'C3' but required in type 'C4'. -+!!! error TS2741: Property 'y' is missing in type 'C3' but required in type 'C4'. - !!! related TS2728 objectTypesIdentityWithPrivates3.ts:21:5: 'y' is declared here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt index a952a7cc64..353e324db2 100644 --- a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt @@ -1,8 +1,12 @@ typeAssertions.ts(5,9): error TS2558: Expected 0 type arguments, but got 1. -typeAssertions.ts(31,12): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -typeAssertions.ts(35,15): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -typeAssertions.ts(37,13): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -typeAssertions.ts(38,13): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. +typeAssertions.ts(31,12): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. +typeAssertions.ts(35,15): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +typeAssertions.ts(37,13): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. +typeAssertions.ts(38,13): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. typeAssertions.ts(44,5): error TS2749: 'numOrStr' refers to a value, but is being used as a type here. Did you mean 'typeof numOrStr'? typeAssertions.ts(44,14): error TS1005: '>' expected. typeAssertions.ts(44,14): error TS2304: Cannot find name 'is'. @@ -54,22 +58,26 @@ typeAssertions.ts(48,50): error TS1128: Declaration or statement expected. someBase = someBase; someBase = someOther; // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. +!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. !!! related TS2728 typeAssertions.ts:15:13: 'p' is declared here. someDerived = someDerived; someDerived = someBase; someDerived = someOther; // Error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x someOther = someDerived; // Error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. +!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. !!! related TS2728 typeAssertions.ts:21:13: 'q' is declared here. someOther = someBase; // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. +!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. !!! related TS2728 typeAssertions.ts:21:13: 'q' is declared here. someOther = someOther; diff --git a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt.diff deleted file mode 100644 index 4d0427559f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typeAssertions.errors.txt.diff +++ /dev/null @@ -1,50 +0,0 @@ ---- old.typeAssertions.errors.txt -+++ new.typeAssertions.errors.txt -@@= skipped -0, +0 lines =@@ - typeAssertions.ts(5,9): error TS2558: Expected 0 type arguments, but got 1. --typeAssertions.ts(31,12): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. --typeAssertions.ts(35,15): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x --typeAssertions.ts(37,13): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. --typeAssertions.ts(38,13): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -+typeAssertions.ts(31,12): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -+typeAssertions.ts(35,15): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -+typeAssertions.ts(37,13): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -+typeAssertions.ts(38,13): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. - typeAssertions.ts(44,5): error TS2749: 'numOrStr' refers to a value, but is being used as a type here. Did you mean 'typeof numOrStr'? - typeAssertions.ts(44,14): error TS1005: '>' expected. - typeAssertions.ts(44,14): error TS2304: Cannot find name 'is'. -@@= skipped -57, +53 lines =@@ - someBase = someBase; - someBase = someOther; // Error - ~~~~~~~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -+!!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. - !!! related TS2728 typeAssertions.ts:15:13: 'p' is declared here. - - someDerived = someDerived; - someDerived = someBase; - someDerived = someOther; // Error - ~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -+!!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x - - someOther = someDerived; // Error - ~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -+!!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. - !!! related TS2728 typeAssertions.ts:21:13: 'q' is declared here. - someOther = someBase; // Error - ~~~~~~~~~~~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -+!!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. - !!! related TS2728 typeAssertions.ts:21:13: 'q' is declared here. - someOther = someOther; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt b/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt index 71f7327074..5ea47a61c6 100644 --- a/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt @@ -1,6 +1,7 @@ typeAssertionsWithIntersectionTypes01.ts(17,9): error TS2352: Conversion of type 'I2' to type 'I1 & I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'p3' is missing in type 'I2' but required in type 'I3'. -typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2741: Property 'p3' is missing in type 'I2' but required in type 'I3'. +typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2352: Conversion of type 'I2' to type 'I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'p3' is missing in type 'I2' but required in type 'I3'. ==== typeAssertionsWithIntersectionTypes01.ts (2 errors) ==== @@ -27,7 +28,8 @@ typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2741: Property 'p3' is m !!! related TS2728 typeAssertionsWithIntersectionTypes01.ts:10:5: 'p3' is declared here. var b = z; ~~~~~ -!!! error TS2741: Property 'p3' is missing in type 'I2' but required in type 'I3'. +!!! error TS2352: Conversion of type 'I2' to type 'I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2352: Property 'p3' is missing in type 'I2' but required in type 'I3'. !!! related TS2728 typeAssertionsWithIntersectionTypes01.ts:10:5: 'p3' is declared here. var c = z; var d = y; diff --git a/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt.diff deleted file mode 100644 index 1b749e610e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typeAssertionsWithIntersectionTypes01.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.typeAssertionsWithIntersectionTypes01.errors.txt -+++ new.typeAssertionsWithIntersectionTypes01.errors.txt -@@= skipped -0, +0 lines =@@ - typeAssertionsWithIntersectionTypes01.ts(17,9): error TS2352: Conversion of type 'I2' to type 'I1 & I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Property 'p3' is missing in type 'I2' but required in type 'I3'. --typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2352: Conversion of type 'I2' to type 'I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'p3' is missing in type 'I2' but required in type 'I3'. -+typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2741: Property 'p3' is missing in type 'I2' but required in type 'I3'. - - - ==== typeAssertionsWithIntersectionTypes01.ts (2 errors) ==== -@@= skipped -27, +26 lines =@@ - !!! related TS2728 typeAssertionsWithIntersectionTypes01.ts:10:5: 'p3' is declared here. - var b = z; - ~~~~~ --!!! error TS2352: Conversion of type 'I2' to type 'I3' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'p3' is missing in type 'I2' but required in type 'I3'. -+!!! error TS2741: Property 'p3' is missing in type 'I2' but required in type 'I3'. - !!! related TS2728 typeAssertionsWithIntersectionTypes01.ts:10:5: 'p3' is declared here. - var c = z; - var d = y; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index cb553f8687..a8e9b0d3d7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -1,28 +1,17 @@ --- old.jsdocTypeTagCast.errors.txt +++ new.jsdocTypeTagCast.errors.txt -@@= skipped -0, +0 lines =@@ --b.js(4,20): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --b.js(45,23): error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. --b.js(49,26): error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x --b.js(51,24): error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. --b.js(52,24): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. +@@= skipped -6, +6 lines =@@ + Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. + b.js(52,24): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -b.js(58,1): error TS2322: Type 'SomeFakeClass' is not assignable to type 'SomeBase'. - Types of property 'p' are incompatible. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. -+b.js(4,31): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -+b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -+b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -+b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -+b.js(52,38): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. b.js(67,2): error TS2322: Type 'string | number' is not assignable to type 'string'. -@@= skipped -20, +12 lines =@@ +@@= skipped -14, +10 lines =@@ ==== a.ts (0 errors) ==== var W: string; @@ -31,49 +20,7 @@ // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); - var W = /** @type {string} */(4); // Error -- ~~~~~~ -+ ~ - !!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - - /** @type {*} */ -@@= skipped -48, +48 lines =@@ - someBase = /** @type {SomeBase} */(someDerived); - someBase = /** @type {SomeBase} */(someBase); - someBase = /** @type {SomeBase} */(someOther); // Error -- ~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -+ ~~~~~~~~~ -+!!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. - !!! related TS2728 b.js:17:9: 'p' is declared here. - - someDerived = /** @type {SomeDerived} */(someDerived); - someDerived = /** @type {SomeDerived} */(someBase); - someDerived = /** @type {SomeDerived} */(someOther); // Error -- ~~~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -+ ~~~~~~~~~ -+!!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x - - someOther = /** @type {SomeOther} */(someDerived); // Error -- ~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -+ ~~~~~~~~~~~ -+!!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. - !!! related TS2728 b.js:28:9: 'q' is declared here. - someOther = /** @type {SomeOther} */(someBase); // Error -- ~~~~~~~~~ --!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. --!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -+ ~~~~~~~~ -+!!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. - !!! related TS2728 b.js:28:9: 'q' is declared here. - someOther = /** @type {SomeOther} */(someOther); - -@@= skipped -28, +24 lines =@@ +@@= skipped -76, +76 lines =@@ someFakeClass = someDerived; someBase = someFakeClass; // Error