diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b704cd3b074..01bd7f49610 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20047,7 +20047,8 @@ namespace ts { if (produceDiagnostics && targetType !== errorType) { const widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { - checkTypeComparableTo(exprType, targetType, errNode, Diagnostics.Type_0_cannot_be_converted_to_type_1); + 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); } } return targetType; @@ -21521,7 +21522,7 @@ namespace ts { // in tagged templates. forEach(node.templateSpans, templateSpan => { if (maybeTypeOfKind(checkExpression(templateSpan.expression), TypeFlags.ESSymbolLike)) { - error(templateSpan.expression, Diagnostics.Type_0_cannot_be_converted_to_type_1, typeToString(esSymbolType), typeToString(stringType)); + error(templateSpan.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8927cbd33b1..b3fc017eb05 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1196,7 +1196,7 @@ "category": "Error", "code": 2351 }, - "Type '{0}' cannot be converted to type '{1}'.": { + "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.": { "category": "Error", "code": 2352 }, @@ -2421,10 +2421,14 @@ "category": "Error", "code": 2730 }, - "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension": { + "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'.": { "category": "Error", "code": 2731 }, + "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension": { + "category": "Error", + "code": 2732 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 628989b006e..799140097cd 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -136,15 +136,8 @@ namespace ts.GoToDefinition { const symbol = typeChecker.getSymbolAtLocation(node); const type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, node); - if (!type) { - return undefined; - } - - if (type.isUnion() && !(type.flags & TypeFlags.Enum)) { - return flatMap(type.types, t => t.symbol && getDefinitionFromSymbol(typeChecker, t.symbol, node)); - } - - return type.symbol && getDefinitionFromSymbol(typeChecker, type.symbol, node); + return type && flatMap(type.isUnion() && !(type.flags & TypeFlags.Enum) ? type.types : [type], t => + t.symbol && getDefinitionFromSymbol(typeChecker, t.symbol, node)); } export function getDefinitionAndBoundSpan(program: Program, sourceFile: SourceFile, position: number): DefinitionInfoAndBoundSpan | undefined { @@ -230,7 +223,7 @@ namespace ts.GoToDefinition { } function getCallSignatureDefinition(): DefinitionInfo[] | undefined { - return isCallExpressionTarget(node) || isNewExpressionTarget(node) || isNameOfFunctionDeclaration(node) + return isCallOrNewExpressionTarget(node) || isNameOfFunctionDeclaration(node) ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) : undefined; } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index ec5eddf9e16..ff7fcd59ef2 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -30,13 +30,11 @@ namespace ts.SignatureHelp { } // Only need to be careful if the user typed a character and signature help wasn't showing. - const shouldCarefullyCheckContext = !!triggerReason && triggerReason.kind === "characterTyped"; + const onlyUseSyntacticOwners = !!triggerReason && triggerReason.kind === "characterTyped"; // Bail out quickly in the middle of a string or comment, don't provide signature help unless the user explicitly requested it. - if (shouldCarefullyCheckContext) { - if (isInString(sourceFile, position, startingToken) || isInComment(sourceFile, position)) { - return undefined; - } + if (onlyUseSyntacticOwners && (isInString(sourceFile, position, startingToken) || isInComment(sourceFile, position))) { + return undefined; } const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); @@ -45,7 +43,7 @@ namespace ts.SignatureHelp { cancellationToken.throwIfCancellationRequested(); // Extra syntactic and semantic filtering of signature help - const candidateInfo = getCandidateInfo(argumentInfo, typeChecker, sourceFile, startingToken, shouldCarefullyCheckContext); + const candidateInfo = getCandidateInfo(argumentInfo, typeChecker, sourceFile, startingToken, onlyUseSyntacticOwners); cancellationToken.throwIfCancellationRequested(); if (!candidateInfo) { @@ -66,35 +64,9 @@ namespace ts.SignatureHelp { const { invocation } = argumentInfo; if (invocation.kind === InvocationKind.Call) { - if (onlyUseSyntacticOwners) { - if (isCallOrNewExpression(invocation.node)) { - const invocationChildren = invocation.node.getChildren(sourceFile); - switch (startingToken.kind) { - case SyntaxKind.OpenParenToken: - if (!contains(invocationChildren, startingToken)) { - return undefined; - } - break; - case SyntaxKind.CommaToken: - const containingList = findContainingList(startingToken); - if (!containingList || !contains(invocationChildren, findContainingList(startingToken))) { - return undefined; - } - break; - case SyntaxKind.LessThanToken: - if (!lessThanFollowsCalledExpression(startingToken, sourceFile, invocation.node.expression)) { - return undefined; - } - break; - default: - return undefined; - } - } - else { - return undefined; - } + if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { + return undefined; } - const candidates: Signature[] = []; const resolvedSignature = checker.getResolvedSignature(invocation.node, candidates, argumentInfo.argumentCount)!; // TODO: GH#18217 return candidates.length === 0 ? undefined : { candidates, resolvedSignature }; @@ -111,6 +83,23 @@ namespace ts.SignatureHelp { } } + function isSyntacticOwner(startingToken: Node, node: CallLikeExpression, sourceFile: SourceFile): boolean { + if (!isCallOrNewExpression(node)) return false; + const invocationChildren = node.getChildren(sourceFile); + switch (startingToken.kind) { + case SyntaxKind.OpenParenToken: + return contains(invocationChildren, startingToken); + case SyntaxKind.CommaToken: { + const containingList = findContainingList(startingToken); + return !!containingList && contains(invocationChildren, containingList); + } + case SyntaxKind.LessThanToken: + return lessThanFollowsCalledExpression(startingToken, sourceFile, node.expression); + default: + return false; + } + } + function createJavaScriptSignatureHelpItems(argumentInfo: ArgumentListInfo, program: Program, cancellationToken: CancellationToken): SignatureHelpItems | undefined { // See if we can find some symbol with the call expression name that has call signatures. const expression = getExpressionFromInvocation(argumentInfo.invocation); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 1d68aa9144d..6f9ffe25b12 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -194,16 +194,20 @@ namespace ts { } export function isCallExpressionTarget(node: Node): boolean { - return isCallOrNewExpressionTarget(node, SyntaxKind.CallExpression); + return isCallOrNewExpressionTargetWorker(node, isCallExpression); } export function isNewExpressionTarget(node: Node): boolean { - return isCallOrNewExpressionTarget(node, SyntaxKind.NewExpression); + return isCallOrNewExpressionTargetWorker(node, isNewExpression); } - function isCallOrNewExpressionTarget(node: Node, kind: SyntaxKind): boolean { + export function isCallOrNewExpressionTarget(node: Node): boolean { + return isCallOrNewExpressionTargetWorker(node, isCallOrNewExpression); + } + + function isCallOrNewExpressionTargetWorker(node: Node, pred: (node: Node) => node is T): boolean { const target = climbPastPropertyAccess(node); - return !!target && !!target.parent && target.parent.kind === kind && (target.parent).expression === target; + return !!target && !!target.parent && pred(target.parent) && target.parent.expression === target; } export function climbPastPropertyAccess(node: Node) { diff --git a/tests/baselines/reference/arrayCast.errors.txt b/tests/baselines/reference/arrayCast.errors.txt index 61463e5557b..ce9d0313825 100644 --- a/tests/baselines/reference/arrayCast.errors.txt +++ b/tests/baselines/reference/arrayCast.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Type '{ foo: string; }[]' cannot be converted to type '{ id: number; }[]'. +tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Conversion of type '{ foo: string; }[]' to type '{ id: number; }[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type '{ foo: string; }' is not comparable to type '{ id: number; }'. Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. @@ -8,7 +8,7 @@ tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Type '{ foo: string; }[]' // has type { foo: string }[], which is not assignable to { id: number }[]. <{ id: number; }[]>[{ foo: "s" }]; ~~~~~~~~ -!!! error TS2352: Type '{ foo: string; }[]' cannot be converted to type '{ id: number; }[]'. +!!! error TS2352: Conversion of type '{ foo: string; }[]' to type '{ id: number; }[]' 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 '{ foo: string; }' is not comparable to type '{ id: number; }'. !!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. diff --git a/tests/baselines/reference/asOperator2.errors.txt b/tests/baselines/reference/asOperator2.errors.txt index 92603c25cb0..711c320ff7a 100644 --- a/tests/baselines/reference/asOperator2.errors.txt +++ b/tests/baselines/reference/asOperator2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/expressions/asOperator/asOperator2.ts(1,9): error TS2352: Type 'number' cannot be converted to type 'string'. +tests/cases/conformance/expressions/asOperator/asOperator2.ts(1,9): 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. ==== tests/cases/conformance/expressions/asOperator/asOperator2.ts (1 errors) ==== var x = 23 as string; ~~~~~~~~~~~~ -!!! error TS2352: Type 'number' cannot be converted to type 'string'. +!!! 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. \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorContextualType.errors.txt b/tests/baselines/reference/asOperatorContextualType.errors.txt index 9431d6123e2..77ebe06fbf9 100644 --- a/tests/baselines/reference/asOperatorContextualType.errors.txt +++ b/tests/baselines/reference/asOperatorContextualType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): error TS2352: Type '(v: number) => number' cannot be converted to type '(x: number) => string'. +tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): error TS2352: Conversion of type '(v: number) => number' to type '(x: number) => string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'number' is not comparable to type 'string'. @@ -6,5 +6,5 @@ tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): // should error var x = (v => v) as (x: number) => string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '(v: number) => number' cannot be converted to type '(x: number) => string'. +!!! error TS2352: Conversion of type '(v: number) => number' to type '(x: number) => string' 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 'number' is not comparable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/asOperatorNames.errors.txt b/tests/baselines/reference/asOperatorNames.errors.txt index 4f957791a24..c634a4a7887 100644 --- a/tests/baselines/reference/asOperatorNames.errors.txt +++ b/tests/baselines/reference/asOperatorNames.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/expressions/asOperator/asOperatorNames.ts(2,9): error TS2352: Type 'number' cannot be converted to type 'string'. +tests/cases/conformance/expressions/asOperator/asOperatorNames.ts(2,9): 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. ==== tests/cases/conformance/expressions/asOperator/asOperatorNames.ts (1 errors) ==== var a = 20; var b = a as string; ~~~~~~~~~~~ -!!! error TS2352: Type 'number' cannot be converted to type 'string'. +!!! 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. var as = "hello"; var as1 = as as string; \ No newline at end of file diff --git a/tests/baselines/reference/castingTuple.errors.txt b/tests/baselines/reference/castingTuple.errors.txt index 344f403906d..c7b00e2a0ca 100644 --- a/tests/baselines/reference/castingTuple.errors.txt +++ b/tests/baselines/reference/castingTuple.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2352: Type '[number, string]' cannot be converted to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property '2' is missing in type '[number, string]'. -tests/cases/conformance/types/tuple/castingTuple.ts(14,15): error TS2352: Type '[number, string, boolean]' cannot be converted to type '[number, string]'. +tests/cases/conformance/types/tuple/castingTuple.ts(14,15): error TS2352: Conversion of type '[number, string, boolean]' to type '[number, string]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'length' are incompatible. Type '3' is not comparable to type '2'. -tests/cases/conformance/types/tuple/castingTuple.ts(15,14): error TS2352: Type '[number, string]' cannot be converted to type '[number, string, boolean]'. -tests/cases/conformance/types/tuple/castingTuple.ts(18,21): error TS2352: Type '[C, D]' cannot be converted to type '[C, D, A]'. +tests/cases/conformance/types/tuple/castingTuple.ts(15,14): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +tests/cases/conformance/types/tuple/castingTuple.ts(18,21): error TS2352: Conversion of type '[C, D]' to type '[C, D, A]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property '2' is missing in type '[C, D]'. -tests/cases/conformance/types/tuple/castingTuple.ts(30,10): error TS2352: Type '[number, string]' cannot be converted to type '[number, number]'. +tests/cases/conformance/types/tuple/castingTuple.ts(30,10): error TS2352: Conversion of type '[number, string]' to type '[number, number]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'string' is not comparable to type 'number'. -tests/cases/conformance/types/tuple/castingTuple.ts(31,10): error TS2352: Type '[C, D]' cannot be converted to type '[A, I]'. +tests/cases/conformance/types/tuple/castingTuple.ts(31,10): error TS2352: Conversion of type '[C, D]' to type '[A, I]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'C' is not comparable to type 'A'. Property 'a' is missing in type 'C'. tests/cases/conformance/types/tuple/castingTuple.ts(32,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. @@ -30,21 +30,21 @@ tests/cases/conformance/types/tuple/castingTuple.ts(33,1): error TS2304: Cannot var emptyObjTuple = <[{}, {}]>numStrTuple; var numStrBoolTuple = <[number, string, boolean]>numStrTuple; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '[number, string]' cannot be converted to type '[number, string, boolean]'. +!!! error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' 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 '2' is missing in type '[number, string]'. var shorter = numStrBoolTuple as [number, string] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '[number, string, boolean]' cannot be converted to type '[number, string]'. +!!! error TS2352: Conversion of type '[number, string, boolean]' to type '[number, string]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. !!! error TS2352: Types of property 'length' are incompatible. !!! error TS2352: Type '3' is not comparable to type '2'. var longer = numStrTuple as [number, string, boolean] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '[number, string]' cannot be converted to type '[number, string, boolean]'. +!!! error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. var classCDTuple: [C, D] = [new C(), new D()]; var interfaceIITuple = <[I, I]>classCDTuple; var classCDATuple = <[C, D, A]>classCDTuple; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '[C, D]' cannot be converted to type '[C, D, A]'. +!!! error TS2352: Conversion of type '[C, D]' to type '[C, D, 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 '2' is missing in type '[C, D]'. var eleFromCDA1 = classCDATuple[2]; // A var eleFromCDA2 = classCDATuple[5]; // C | D | A @@ -59,11 +59,11 @@ tests/cases/conformance/types/tuple/castingTuple.ts(33,1): error TS2304: Cannot // error var t3 = <[number, number]>numStrTuple; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '[number, string]' cannot be converted to type '[number, number]'. +!!! error TS2352: Conversion of type '[number, string]' to type '[number, number]' 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 'string' is not comparable to type 'number'. var t9 = <[A, I]>classCDTuple; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '[C, D]' cannot be converted to type '[A, I]'. +!!! error TS2352: Conversion of type '[C, D]' to type '[A, I]' 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' is not comparable to type 'A'. !!! error TS2352: Property 'a' is missing in type 'C'. var array1 = numStrTuple; diff --git a/tests/baselines/reference/contextualTyping39.errors.txt b/tests/baselines/reference/contextualTyping39.errors.txt index 9081480f4ba..5c399faeb62 100644 --- a/tests/baselines/reference/contextualTyping39.errors.txt +++ b/tests/baselines/reference/contextualTyping39.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping39.ts(1,11): error TS2352: Type '() => string' cannot be converted to type '() => number'. +tests/cases/compiler/contextualTyping39.ts(1,11): error TS2352: Conversion of type '() => string' to type '() => number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'string' is not comparable to type 'number'. ==== tests/cases/compiler/contextualTyping39.ts (1 errors) ==== var foo = <{ (): number; }> function() { return "err"; }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '() => string' cannot be converted to type '() => number'. +!!! error TS2352: Conversion of type '() => string' to type '() => number' 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 'string' is not comparable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping41.errors.txt b/tests/baselines/reference/contextualTyping41.errors.txt index 418d435e7fe..afa94b8e333 100644 --- a/tests/baselines/reference/contextualTyping41.errors.txt +++ b/tests/baselines/reference/contextualTyping41.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping41.ts(1,11): error TS2352: Type '() => string' cannot be converted to type '{ (): number; (i: number): number; }'. +tests/cases/compiler/contextualTyping41.ts(1,11): error TS2352: Conversion of type '() => string' to type '{ (): number; (i: number): number; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'string' is not comparable to type 'number'. ==== tests/cases/compiler/contextualTyping41.ts (1 errors) ==== var foo = <{():number; (i:number):number; }> (function(){return "err";}); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '() => string' cannot be converted to type '{ (): number; (i: number): number; }'. +!!! error TS2352: Conversion of type '() => string' to type '{ (): number; (i: number): number; }' 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 'string' is not comparable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt b/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt index d46963caeed..805f25d8dbc 100644 --- a/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt +++ b/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt @@ -2,9 +2,9 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(4,19): error TS2345: Ar tests/cases/compiler/defaultArgsInFunctionExpressions.ts(5,1): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(8,20): error TS2322: Type '3' is not assignable to type 'string'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(11,1): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/compiler/defaultArgsInFunctionExpressions.ts(14,51): error TS2352: Type 'string' cannot be converted to type 'number'. +tests/cases/compiler/defaultArgsInFunctionExpressions.ts(14,51): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(17,41): error TS2322: Type '""' is not assignable to type 'number'. -tests/cases/compiler/defaultArgsInFunctionExpressions.ts(20,62): error TS2352: Type 'string' cannot be converted to type 'number'. +tests/cases/compiler/defaultArgsInFunctionExpressions.ts(20,62): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2708: Cannot use namespace 'T' as a value. @@ -32,7 +32,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2708: C // Contextually type the default arg with the type annotation var f3 = function (a: (s: string) => any = (s) => s) { }; ~~~~~~~~~ -!!! error TS2352: Type 'string' cannot be converted to type 'number'. +!!! error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. // Type check using the function's contextual type var f4: (a: number) => void = function (a = "") { }; @@ -42,7 +42,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2708: C // Contextually type the default arg using the function's contextual type var f5: (a: (s: string) => any) => void = function (a = s => s) { }; ~~~~~~~~~ -!!! error TS2352: Type 'string' cannot be converted to type 'number'. +!!! error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. // Instantiated module module T { } diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index 173683297f9..879789e4b23 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/fuzzy.ts(13,18): error TS2420: Class 'C' incorrectly implem Property 'alsoWorks' is missing in type 'C'. tests/cases/compiler/fuzzy.ts(21,34): error TS2322: Type 'this' is not assignable to type 'I'. Type 'C' is not assignable to type 'I'. -tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' cannot be converted to type 'R'. +tests/cases/compiler/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; }'. @@ -40,7 +40,7 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' canno worksToo():R { return ({ oneI: this }); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '{ oneI: this; }' cannot be converted to 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; }'. } } diff --git a/tests/baselines/reference/genericTypeAssertions1.errors.txt b/tests/baselines/reference/genericTypeAssertions1.errors.txt index aa5f14f5da8..b4c7a165a91 100644 --- a/tests/baselines/reference/genericTypeAssertions1.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions1.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/genericTypeAssertions1.ts(3,5): error TS2322: Type 'A>' is not assignable to type 'A'. Type 'A' is not assignable to type 'number'. -tests/cases/compiler/genericTypeAssertions1.ts(4,21): error TS2352: Type 'A' cannot be converted to type 'A>'. +tests/cases/compiler/genericTypeAssertions1.ts(4,21): error TS2352: Conversion of type 'A' 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. Type 'number' is not comparable to type 'A'. @@ -18,5 +18,5 @@ tests/cases/compiler/genericTypeAssertions1.ts(4,21): error TS2352: Type 'A>' is not assignable to type 'A'. !!! error TS2322: Type 'A' is not assignable to type 'number'. ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'A' cannot be converted to type 'A>'. +!!! error TS2352: Conversion of type 'A' 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: Type 'number' is not comparable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeAssertions2.errors.txt b/tests/baselines/reference/genericTypeAssertions2.errors.txt index 756690f1783..df3093cbc8a 100644 --- a/tests/baselines/reference/genericTypeAssertions2.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions2.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/genericTypeAssertions2.ts(10,5): error TS2322: Type 'B' is not assignable to type 'B'. Property 'bar' is missing in type 'A'. -tests/cases/compiler/genericTypeAssertions2.ts(13,21): error TS2352: Type 'undefined[]' cannot be converted to type 'A'. +tests/cases/compiler/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[]'. @@ -33,5 +33,5 @@ tests/cases/compiler/genericTypeAssertions2.ts(13,21): error TS2352: Type 'undef var r4: A = >new A(); var r5: A = >[]; // error ~~~~~~~~~~~~~ -!!! error TS2352: Type 'undefined[]' cannot be converted to 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[]'. \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeAssertions4.errors.txt b/tests/baselines/reference/genericTypeAssertions4.errors.txt index 401834930f3..4c23bd6d458 100644 --- a/tests/baselines/reference/genericTypeAssertions4.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions4.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/genericTypeAssertions4.ts(19,5): error TS2322: Type 'A' is not assignable to type 'T'. tests/cases/compiler/genericTypeAssertions4.ts(20,5): error TS2322: Type 'B' is not assignable to type 'T'. tests/cases/compiler/genericTypeAssertions4.ts(21,5): error TS2322: Type 'C' is not assignable to type 'T'. -tests/cases/compiler/genericTypeAssertions4.ts(23,9): error TS2352: Type 'B' cannot be converted to type 'T'. -tests/cases/compiler/genericTypeAssertions4.ts(24,9): error TS2352: Type 'C' cannot be converted to type 'T'. +tests/cases/compiler/genericTypeAssertions4.ts(23,9): error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +tests/cases/compiler/genericTypeAssertions4.ts(24,9): error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ==== tests/cases/compiler/genericTypeAssertions4.ts (5 errors) ==== @@ -36,8 +36,8 @@ tests/cases/compiler/genericTypeAssertions4.ts(24,9): error TS2352: Type 'C' can y = a; y = b; // error: cannot convert B to T ~~~~ -!!! error TS2352: Type 'B' cannot be converted to type 'T'. +!!! error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. y = c; // error: cannot convert C to T ~~~~ -!!! error TS2352: Type 'C' cannot be converted to type 'T'. +!!! error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. } \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeAssertions5.errors.txt b/tests/baselines/reference/genericTypeAssertions5.errors.txt index 45f76073363..e01b90d72a5 100644 --- a/tests/baselines/reference/genericTypeAssertions5.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions5.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/genericTypeAssertions5.ts(19,5): error TS2322: Type 'A' is not assignable to type 'T'. tests/cases/compiler/genericTypeAssertions5.ts(20,5): error TS2322: Type 'B' is not assignable to type 'T'. tests/cases/compiler/genericTypeAssertions5.ts(21,5): error TS2322: Type 'C' is not assignable to type 'T'. -tests/cases/compiler/genericTypeAssertions5.ts(23,9): error TS2352: Type 'B' cannot be converted to type 'T'. -tests/cases/compiler/genericTypeAssertions5.ts(24,9): error TS2352: Type 'C' cannot be converted to type 'T'. +tests/cases/compiler/genericTypeAssertions5.ts(23,9): error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +tests/cases/compiler/genericTypeAssertions5.ts(24,9): error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ==== tests/cases/compiler/genericTypeAssertions5.ts (5 errors) ==== @@ -36,8 +36,8 @@ tests/cases/compiler/genericTypeAssertions5.ts(24,9): error TS2352: Type 'C' can y = a; y = b; // error: cannot convert B to T ~~~~ -!!! error TS2352: Type 'B' cannot be converted to type 'T'. +!!! error TS2352: Conversion of type 'B' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. y = c; // error: cannot convert C to T ~~~~ -!!! error TS2352: Type 'C' cannot be converted to type 'T'. +!!! error TS2352: Conversion of type 'C' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. } \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeAssertions6.errors.txt b/tests/baselines/reference/genericTypeAssertions6.errors.txt index 1bda683b88a..ef65803a47d 100644 --- a/tests/baselines/reference/genericTypeAssertions6.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions6.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/genericTypeAssertions6.ts(8,13): error TS2352: Type 'U' cannot be converted to type 'T'. -tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Type 'T' cannot be converted to type 'U'. -tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Type 'U' cannot be converted to type 'T'. +tests/cases/compiler/genericTypeAssertions6.ts(8,13): error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Conversion of type 'T' to type 'U' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'Date' is not comparable to type 'T'. @@ -14,10 +14,10 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Type 'U' ca f(x: T, y: U) { x = y; ~~~~ -!!! error TS2352: Type 'U' cannot be converted to type 'T'. +!!! error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. y = x; ~~~~ -!!! error TS2352: Type 'T' cannot be converted to type 'U'. +!!! error TS2352: Conversion of type 'T' to type 'U' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. } } @@ -29,7 +29,7 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Type 'U' ca var d = new Date(); var e = new Date(); ~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'U' cannot be converted to type 'T'. +!!! error TS2352: Conversion of type 'U' to type 'T' 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 'Date' is not comparable to type 'T'. } } diff --git a/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt b/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt index c62c7868e10..89a1724ea9a 100644 --- a/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt +++ b/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/dynamicImport/1.ts(4,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. Type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not assignable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. -tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Type 'Promise' cannot be converted to type 'Promise'. +tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Conversion of type 'Promise' to type 'Promise' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not comparable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. @@ -23,7 +23,7 @@ tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Type 'Promise; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'Promise' cannot be converted to type 'Promise'. +!!! error TS2352: Conversion of type 'Promise' to type 'Promise' 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 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not comparable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. !!! error TS2352: Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. let p3: Promise = import("./defaultPath"); diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index e5fbfbdbee8..5b7ca138339 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -76,7 +76,7 @@ tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assi tests/cases/compiler/intTypeCheck.ts(183,5): error TS2322: Type 'Object' is not assignable to type 'i7'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? Type 'Object' provides no match for the signature 'new (): any'. -tests/cases/compiler/intTypeCheck.ts(185,17): error TS2352: Type 'Base' cannot be converted to type 'i7'. +tests/cases/compiler/intTypeCheck.ts(185,17): error TS2352: Conversion of type 'Base' to type 'i7' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'Base' provides no match for the signature 'new (): any'. tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is not assignable to type 'i7'. Type '() => void' provides no match for the signature 'new (): any'. @@ -408,7 +408,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj69: i7 = new obj66; var obj70: i7 = new Base; ~~~~~~~~~~~~ -!!! error TS2352: Type 'Base' cannot be converted to type 'i7'. +!!! error TS2352: Conversion of type 'Base' to type 'i7' 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 'Base' provides no match for the signature 'new (): any'. var obj71: i7 = null; var obj72: i7 = function () { }; diff --git a/tests/baselines/reference/jsdocTypeTagCast.errors.txt b/tests/baselines/reference/jsdocTypeTagCast.errors.txt index 8cbe096de35..a84d31a341b 100644 --- a/tests/baselines/reference/jsdocTypeTagCast.errors.txt +++ b/tests/baselines/reference/jsdocTypeTagCast.errors.txt @@ -1,17 +1,17 @@ -tests/cases/conformance/jsdoc/b.js(4,13): error TS2352: Type 'number' cannot be converted to type 'string'. -tests/cases/conformance/jsdoc/b.js(45,16): error TS2352: Type 'SomeOther' cannot be converted to type 'SomeBase'. +tests/cases/conformance/jsdoc/b.js(4,13): 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. +tests/cases/conformance/jsdoc/b.js(45,16): 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'. -tests/cases/conformance/jsdoc/b.js(49,19): error TS2352: Type 'SomeOther' cannot be converted to type 'SomeDerived'. +tests/cases/conformance/jsdoc/b.js(49,19): 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. Property 'x' is missing in type 'SomeOther'. -tests/cases/conformance/jsdoc/b.js(51,17): error TS2352: Type 'SomeDerived' cannot be converted to type 'SomeOther'. +tests/cases/conformance/jsdoc/b.js(51,17): 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'. -tests/cases/conformance/jsdoc/b.js(52,17): error TS2352: Type 'SomeBase' cannot be converted to type 'SomeOther'. +tests/cases/conformance/jsdoc/b.js(52,17): 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'. tests/cases/conformance/jsdoc/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'. -tests/cases/conformance/jsdoc/b.js(66,8): error TS2352: Type 'boolean' cannot be converted to type 'string | number'. +tests/cases/conformance/jsdoc/b.js(66,8): error TS2352: Conversion of type 'boolean' to type 'string | number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. tests/cases/conformance/jsdoc/b.js(66,15): error TS2304: Cannot find name 'numOrStr'. tests/cases/conformance/jsdoc/b.js(66,24): error TS1005: '}' expected. tests/cases/conformance/jsdoc/b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. @@ -29,7 +29,7 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u var W = /** @type {string} */(4); // Error ~~~~~~~~~~~~~~ -!!! error TS2352: Type 'number' cannot be converted to type 'string'. +!!! 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 {*} */ var a; @@ -72,23 +72,23 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u someBase = /** @type {SomeBase} */(someBase); someBase = /** @type {SomeBase} */(someOther); // Error ~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeOther' cannot be converted to 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'. someDerived = /** @type {SomeDerived} */(someDerived); someDerived = /** @type {SomeDerived} */(someBase); someDerived = /** @type {SomeDerived} */(someOther); // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeOther' cannot be converted to type 'SomeDerived'. +!!! 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: Property 'x' is missing in type 'SomeOther'. someOther = /** @type {SomeOther} */(someDerived); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeDerived' cannot be converted to 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'. someOther = /** @type {SomeOther} */(someBase); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeBase' cannot be converted to 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'. someOther = /** @type {SomeOther} */(someOther); @@ -110,7 +110,7 @@ tests/cases/conformance/jsdoc/b.js(67,8): error TS2454: Variable 'numOrStr' is u var str; if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error ~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'boolean' cannot be converted to type 'string | number'. +!!! error TS2352: Conversion of type 'boolean' to type 'string | number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ~~~~~~~~ !!! error TS2304: Cannot find name 'numOrStr'. ~~ diff --git a/tests/baselines/reference/literals-negative.errors.txt b/tests/baselines/reference/literals-negative.errors.txt index 2024066d9f2..18ac3c27141 100644 --- a/tests/baselines/reference/literals-negative.errors.txt +++ b/tests/baselines/reference/literals-negative.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/literals-negative.ts(5,9): error TS2352: Type 'number' cannot be converted to type 'boolean'. +tests/cases/compiler/literals-negative.ts(5,9): error TS2352: Conversion of type 'number' to type 'boolean' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ==== tests/cases/compiler/literals-negative.ts (1 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/literals-negative.ts(5,9): error TS2352: Type 'number' cann var s = (null); var b = (n); ~~~~~~~~~~~~ -!!! error TS2352: Type 'number' cannot be converted to type 'boolean'. +!!! error TS2352: Conversion of type 'number' to type 'boolean' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. function isVoid() : void { } diff --git a/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt b/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt index 769353b9965..3f30b649c96 100644 --- a/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt +++ b/tests/baselines/reference/noImplicitAnyInCastExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noImplicitAnyInCastExpression.ts(15,2): error TS2352: Type '{ c: null; }' cannot be converted to type 'IFoo'. +tests/cases/compiler/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. Property 'a' is missing in type '{ c: null; }'. @@ -19,5 +19,5 @@ tests/cases/compiler/noImplicitAnyInCastExpression.ts(15,2): error TS2352: Type // Neither types is assignable to each other ({ c: null }); ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '{ c: null; }' cannot be converted to type 'IFoo'. +!!! 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: Property 'a' is missing in type '{ c: null; }'. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitSymbolToString.errors.txt b/tests/baselines/reference/noImplicitSymbolToString.errors.txt index 6dae5c5d76f..cb664d9a8b9 100644 --- a/tests/baselines/reference/noImplicitSymbolToString.errors.txt +++ b/tests/baselines/reference/noImplicitSymbolToString.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/noImplicitSymbolToString.ts(6,30): error TS2352: Type 'symbol' cannot be converted to type 'string'. +tests/cases/compiler/noImplicitSymbolToString.ts(6,30): error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. tests/cases/compiler/noImplicitSymbolToString.ts(7,30): error TS2469: The '+' operator cannot be applied to type 'symbol'. tests/cases/compiler/noImplicitSymbolToString.ts(8,8): error TS2469: The '+=' operator cannot be applied to type 'symbol'. -tests/cases/compiler/noImplicitSymbolToString.ts(13,47): error TS2352: Type 'symbol' cannot be converted to type 'string'. -tests/cases/compiler/noImplicitSymbolToString.ts(13,90): error TS2352: Type 'symbol' cannot be converted to type 'string'. +tests/cases/compiler/noImplicitSymbolToString.ts(13,47): error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. +tests/cases/compiler/noImplicitSymbolToString.ts(13,90): error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. ==== tests/cases/compiler/noImplicitSymbolToString.ts (5 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/noImplicitSymbolToString.ts(13,90): error TS2352: Type 'sym const templateStr = `hello ${symbol}`; ~~~~~~ -!!! error TS2352: Type 'symbol' cannot be converted to type 'string'. +!!! error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. const appendStr = "hello " + symbol; ~~~~~~ !!! error TS2469: The '+' operator cannot be applied to type 'symbol'. @@ -26,7 +26,7 @@ tests/cases/compiler/noImplicitSymbolToString.ts(13,90): error TS2352: Type 'sym const templateStrUnion = `union with number ${symbolUnionNumber} and union with string ${symbolUnionString}`; ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'symbol' cannot be converted to type 'string'. +!!! error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'symbol' cannot be converted to type 'string'. +!!! error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'. \ No newline at end of file diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt b/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt index 2342065605b..983548016e8 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts(25,1): error TS2352: Type 'C3' cannot be converted to type 'C4'. +tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/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'. @@ -29,5 +29,5 @@ tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectType var c3: C3; c3; // Should fail (private x originates in the same declaration, but different types) ~~~~~~ -!!! error TS2352: Type 'C3' cannot be converted to 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'. \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModule.errors.txt b/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModule.errors.txt index 4b2e568dd9a..ce39b7dbdb8 100644 --- a/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModule.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModule.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/file1.ts(1,21): error TS2731: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension -tests/cases/compiler/file1.ts(3,21): error TS2731: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension +tests/cases/compiler/file1.ts(1,21): error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension +tests/cases/compiler/file1.ts(3,21): error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension ==== tests/cases/compiler/file1.ts (2 errors) ==== import b1 = require('./b.json'); // error ~~~~~~~~~~ -!!! error TS2731: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension +!!! error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension let x = b1.a; import b2 = require('./b.json'); // error ~~~~~~~~~~ -!!! error TS2731: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension +!!! error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension if (x) { let b = b2.b; x = (b1.b === b); diff --git a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt index c03b08bd0ac..8cb9e8203e7 100644 --- a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt +++ b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(3,9): error TS2367: This condition will always return 'false' since the types '"foo"' and '"baz"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,9): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. -tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,19): error TS2352: Type 'string' cannot be converted to type 'number'. +tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,19): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ==== tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts (3 errors) ==== @@ -14,5 +14,5 @@ tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparis ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. ~~~~~~~~~~~~~ -!!! error TS2352: Type 'string' cannot be converted to type 'number'. +!!! error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. var d = "foo" === ("bar" as EnhancedString); \ No newline at end of file diff --git a/tests/baselines/reference/typeAssertions.errors.txt b/tests/baselines/reference/typeAssertions.errors.txt index cefc15b8e23..ad6065b0755 100644 --- a/tests/baselines/reference/typeAssertions.errors.txt +++ b/tests/baselines/reference/typeAssertions.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(5,9): error TS2558: Expected 0 type arguments, but got 1. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(31,12): error TS2352: Type 'SomeOther' cannot be converted to type 'SomeBase'. +tests/cases/conformance/expressions/typeAssertions/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'. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(35,15): error TS2352: Type 'SomeOther' cannot be converted to type 'SomeDerived'. +tests/cases/conformance/expressions/typeAssertions/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. Property 'x' is missing in type 'SomeOther'. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(37,13): error TS2352: Type 'SomeDerived' cannot be converted to type 'SomeOther'. +tests/cases/conformance/expressions/typeAssertions/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'. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(38,13): error TS2352: Type 'SomeBase' cannot be converted to type 'SomeOther'. +tests/cases/conformance/expressions/typeAssertions/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'. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,5): error TS2304: Cannot find name 'numOrStr'. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,14): error TS1005: '>' expected. @@ -58,23 +58,23 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): err someBase = someBase; someBase = someOther; // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeOther' cannot be converted to 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'. someDerived = someDerived; someDerived = someBase; someDerived = someOther; // Error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeOther' cannot be converted to type 'SomeDerived'. +!!! 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: Property 'x' is missing in type 'SomeOther'. someOther = someDerived; // Error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeDerived' cannot be converted to 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'. someOther = someBase; // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'SomeBase' cannot be converted to 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'. someOther = someOther; diff --git a/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt b/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt index 42ed640e8fc..16a2a726915 100644 --- a/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt +++ b/tests/baselines/reference/typeAssertionsWithIntersectionTypes01.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts(17,9): error TS2352: Type 'I2' cannot be converted to type 'I1 & I3'. +tests/cases/conformance/types/typeRelationships/comparable/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. Type 'I2' is not comparable to type 'I3'. Property 'p3' is missing in type 'I2'. -tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts(18,9): error TS2352: Type 'I2' cannot be converted to type 'I3'. +tests/cases/conformance/types/typeRelationships/comparable/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. ==== tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithIntersectionTypes01.ts (2 errors) ==== @@ -23,12 +23,12 @@ tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithInt var a = z; ~~~~~~~~~~ -!!! error TS2352: Type 'I2' cannot be converted to type 'I1 & I3'. +!!! 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. !!! error TS2352: Type 'I2' is not comparable to type 'I3'. !!! error TS2352: Property 'p3' is missing in type 'I2'. var b = z; ~~~~~ -!!! error TS2352: Type 'I2' cannot be converted to 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. var c = z; var d = y; \ No newline at end of file diff --git a/tests/baselines/reference/typeAssertionsWithUnionTypes01.errors.txt b/tests/baselines/reference/typeAssertionsWithUnionTypes01.errors.txt index 7bc2a9df9b3..665b49a05cf 100644 --- a/tests/baselines/reference/typeAssertionsWithUnionTypes01.errors.txt +++ b/tests/baselines/reference/typeAssertionsWithUnionTypes01.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithUnionTypes01.ts(14,9): error TS2352: Type 'I1' cannot be converted to type 'number'. +tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithUnionTypes01.ts(14,9): error TS2352: Conversion of type 'I1' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ==== tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithUnionTypes01.ts (1 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/comparable/typeAssertionsWithUni var a = z; var b = z; ~~~~~~~~~ -!!! error TS2352: Type 'I1' cannot be converted to type 'number'. +!!! error TS2352: Conversion of type 'I1' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. var c = z; var d = y; \ No newline at end of file