Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 967911c

Browse files
authored
Report assignability errors on the return/yield keywords (microsoft#52943)
1 parent 5240f06 commit 967911c

File tree

53 files changed

+92
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+92
-90
lines changed

src/compiler/utilities.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,13 +2179,14 @@ function getErrorSpanForArrowFunction(sourceFile: SourceFile, node: ArrowFunctio
21792179
export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan {
21802180
let errorNode: Node | undefined = node;
21812181
switch (node.kind) {
2182-
case SyntaxKind.SourceFile:
2182+
case SyntaxKind.SourceFile: {
21832183
const pos = skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false);
21842184
if (pos === sourceFile.text.length) {
21852185
// file is empty - return span for the beginning of the file
21862186
return createTextSpan(0, 0);
21872187
}
21882188
return getSpanOfTokenAtPosition(sourceFile, pos);
2189+
}
21892190
// This list is a work in progress. Add missing node kinds to improve their error
21902191
// spans.
21912192
case SyntaxKind.VariableDeclaration:
@@ -2210,10 +2211,16 @@ export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpa
22102211
case SyntaxKind.ArrowFunction:
22112212
return getErrorSpanForArrowFunction(sourceFile, node as ArrowFunction);
22122213
case SyntaxKind.CaseClause:
2213-
case SyntaxKind.DefaultClause:
2214+
case SyntaxKind.DefaultClause: {
22142215
const start = skipTrivia(sourceFile.text, (node as CaseOrDefaultClause).pos);
22152216
const end = (node as CaseOrDefaultClause).statements.length > 0 ? (node as CaseOrDefaultClause).statements[0].pos : (node as CaseOrDefaultClause).end;
22162217
return createTextSpanFromBounds(start, end);
2218+
}
2219+
case SyntaxKind.ReturnStatement:
2220+
case SyntaxKind.YieldExpression: {
2221+
const pos = skipTrivia(sourceFile.text, (node as ReturnStatement | YieldExpression).pos);
2222+
return getSpanOfTokenAtPosition(sourceFile, pos);
2223+
}
22172224
}
22182225

22192226
if (errorNode === undefined) {

tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2
88
class LanguageSpec_section_4_5_error_cases {
99
public set AnnotatedSetter_SetterFirst(a: number) { }
1010
public get AnnotatedSetter_SetterFirst() { return ""; }
11-
~~~~~~~~~~
11+
~~~~~~
1212
!!! error TS2322: Type 'string' is not assignable to type 'number'.
1313

1414
public get AnnotatedSetter_SetterLast() { return ""; }
15-
~~~~~~~~~~
15+
~~~~~~
1616
!!! error TS2322: Type 'string' is not assignable to type 'number'.
1717
public set AnnotatedSetter_SetterLast(a: number) { }
1818

tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2
2828
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<string>'?
2929
const c = async () => {
3030
return 0
31-
~~~~~~~~
31+
~~~~~~
3232
!!! error TS2322: Type 'number' is not assignable to type 'string'.
3333
}
3434

tests/baselines/reference/baseConstraintOfDecorator.errors.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,17 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(12,18): error TS2545: A mixin
77
==== tests/cases/compiler/baseConstraintOfDecorator.ts (3 errors) ====
88
export function classExtender<TFunction>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
99
return class decoratorFunc extends superClass {
10-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
~~~~~~
11+
!!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
12+
!!! error TS2322: 'TFunction' could be instantiated with an arbitrary type which could be unrelated to 'typeof decoratorFunc'.
1113
~~~~~~~~~~
1214
!!! error TS2507: Type 'TFunction' is not a constructor function type.
1315
!!! related TS2735 tests/cases/compiler/baseConstraintOfDecorator.ts:1:31: Did you mean for 'TFunction' to be constrained to type 'new (...args: any[]) => unknown'?
1416
constructor(...args: any[]) {
15-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1617
super(...args);
17-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1818
_instanceModifier(this, args);
19-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019
}
21-
~~~~~~~~~
2220
};
23-
~~~~~~
24-
!!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
25-
!!! error TS2322: 'TFunction' could be instantiated with an arbitrary type which could be unrelated to 'typeof decoratorFunc'.
2621
}
2722

2823
class MyClass { private x; }

tests/baselines/reference/checkJsdocReturnTag2.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tests/cases/conformance/jsdoc/returns.js(13,5): error TS2322: Type 'number | boo
1212
*/
1313
function f() {
1414
return 5;
15-
~~~~~~~~~
15+
~~~~~~
1616
!!! error TS2322: Type 'number' is not assignable to type 'string'.
1717
}
1818

@@ -21,7 +21,7 @@ tests/cases/conformance/jsdoc/returns.js(13,5): error TS2322: Type 'number | boo
2121
*/
2222
function f1() {
2323
return 5 || true;
24-
~~~~~~~~~~~~~~~~~
24+
~~~~~~
2525
!!! error TS2322: Type 'number | boolean' is not assignable to type 'string | number'.
2626
!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
2727
}

tests/baselines/reference/checkJsdocTypeTag5.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ tests/cases/conformance/jsdoc/test.js(34,5): error TS2322: Type '1 | 2' is not a
1313
// all 6 should error on return statement/expression
1414
/** @type {(x: number) => string} */
1515
function h(x) { return x }
16-
~~~~~~~~
16+
~~~~~~
1717
!!! error TS2322: Type 'number' is not assignable to type 'string'.
1818
/** @type {(x: number) => string} */
1919
var f = x => x
2020
~
2121
!!! error TS2322: Type 'number' is not assignable to type 'string'.
2222
/** @type {(x: number) => string} */
2323
var g = function (x) { return x }
24-
~~~~~~~~
24+
~~~~~~
2525
!!! error TS2322: Type 'number' is not assignable to type 'string'.
2626

2727
/** @type {{ (x: number): string }} */
2828
function i(x) { return x }
29-
~~~~~~~~
29+
~~~~~~
3030
!!! error TS2322: Type 'number' is not assignable to type 'string'.
3131
/** @type {{ (x: number): string }} */
3232
var j = x => x
3333
~
3434
!!! error TS2322: Type 'number' is not assignable to type 'string'.
3535
/** @type {{ (x: number): string }} */
3636
var k = function (x) { return x }
37-
~~~~~~~~
37+
~~~~~~
3838
!!! error TS2322: Type 'number' is not assignable to type 'string'.
3939

4040

tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type 'strin
1919
/** @type {function(number): number} */
2020
method1(n1) {
2121
return "42";
22-
~~~~~~~~~~~~
22+
~~~~~~
2323
!!! error TS2322: Type 'string' is not assignable to type 'number'.
2424
},
2525
/** @type {function(number): number} */

tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
5353
export function makeNewChannel<T extends ChannelType>(type: T): NewChannel<ChannelOfType<T>> {
5454
const localChannelId = `blahblahblah`;
5555
return { type, localChannelId };
56-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56+
~~~~~~
5757
!!! error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'NewChannel<ChannelOfType<T, TextChannel> | ChannelOfType<T, EmailChannel>>'.
5858
!!! error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick<ChannelOfType<T, TextChannel> | ChannelOfType<T, EmailChannel>, "type">'.
5959
!!! error TS2322: Types of property 'type' are incompatible.

tests/baselines/reference/conditionalTypeAssignabilityWhenDeferred.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ tests/cases/compiler/conditionalTypeAssignabilityWhenDeferred.ts(116,3): error T
129129

130130
function f3<Q extends (arg: any) => any>(x: Q): InferBecauseWhyNot<Q> {
131131
return x;
132-
~~~~~~~~~
132+
~~~~~~
133133
!!! error TS2322: Type 'Q' is not assignable to type 'InferBecauseWhyNot<Q>'.
134134
!!! error TS2322: Type '(arg: any) => any' is not assignable to type 'InferBecauseWhyNot<Q>'.
135135
}
@@ -142,7 +142,7 @@ tests/cases/compiler/conditionalTypeAssignabilityWhenDeferred.ts(116,3): error T
142142
x: Q
143143
): InferBecauseWhyNotDistributive<Q> {
144144
return x; // should fail
145-
~~~~~~~~~
145+
~~~~~~
146146
!!! error TS2322: Type 'Q' is not assignable to type 'InferBecauseWhyNotDistributive<Q>'.
147147
!!! error TS2322: Type '(arg: any) => any' is not assignable to type 'InferBecauseWhyNotDistributive<Q>'.
148148
}

tests/baselines/reference/constEnumPropertyAccess1.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts(25,9): error TS23
2727
[G.A]() { }
2828
get [G.B]() {
2929
return true;
30-
~~~~~~~~~~~~
30+
~~~~~~
3131
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
3232
}
3333
set [G.B](x: number) { }

tests/baselines/reference/constructorReturnsInvalidType.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ tests/cases/compiler/constructorReturnsInvalidType.ts(3,9): error TS2409: Return
66
class X {
77
constructor() {
88
return 1;
9-
~~~~~~~~~
9+
~~~~~~
1010
!!! error TS2322: Type 'number' is not assignable to type 'X'.
11-
~~~~~~~~~
11+
~~~~~~
1212
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class.
1313
}
1414
foo() { }

tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl
1818
x: number;
1919
constructor() {
2020
return 1; // error
21-
~~~~~~~~~
21+
~~~~~~
2222
!!! error TS2322: Type 'number' is not assignable to type 'D'.
23-
~~~~~~~~~
23+
~~~~~~
2424
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class.
2525
}
2626
}
@@ -36,7 +36,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl
3636
x: T;
3737
constructor() {
3838
return { x: 1 }; // error
39-
~~~~~~~~~~~~~~~~
39+
~~~~~~
4040
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class.
4141
~
4242
!!! error TS2322: Type 'number' is not assignable to type 'T'.

tests/baselines/reference/derivedGenericClassWithAny.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC
3838
class E<T extends string> extends D {
3939
x: T;
4040
get X(): T { return ''; } // error
41-
~~~~~~~~~~
41+
~~~~~~
4242
!!! error TS2322: Type 'string' is not assignable to type 'T'.
4343
!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
4444
foo(): T {
4545
return ''; // error
46-
~~~~~~~~~~
46+
~~~~~~
4747
!!! error TS2322: Type 'string' is not assignable to type 'T'.
4848
!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
4949
}

tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts(3,3): error
66
async function foo<T>(x: T): Promise<T> {
77
let yaddable = await getXOrYadda(x);
88
return yaddable;
9-
~~~~~~~~~~~~~~~~
9+
~~~~~~
1010
!!! error TS2322: Type 'Yadda | Awaited<T>' is not assignable to type 'T'.
1111
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Yadda | Awaited<T>'.
1212
}

tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts(4
4545
const result = foos == null ? {} : mapValues(foos, f => f.foo);
4646
// This line _should_ fail, because `result` is not the right type.
4747
return result;
48-
~~~~~~~~~~~~~~
48+
~~~~~~
4949
!!! error TS2322: Type 'Dictionary<string>' is not assignable to type 'Record<string, Bar>'.
5050
!!! error TS2322: 'string' index signatures are incompatible.
5151
!!! error TS2322: Type 'string' is not assignable to type 'Bar'.

tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts(4
4646
const result = foos == null ? {} : mapValues(foos, f => f.foo);
4747
// This line _should_ fail, because `result` is not the right type.
4848
return result;
49-
~~~~~~~~~~~~~~
49+
~~~~~~
5050
!!! error TS2322: Type 'Dictionary<string>' is not assignable to type 'Record<string, Bar>'.
5151
!!! error TS2322: 'string' index signatures are incompatible.
5252
!!! error TS2322: Type 'string' is not assignable to type 'Bar'.

tests/baselines/reference/errorOnFunctionReturnType.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests/cases/conformance/jsdoc/foo.js(45,18): error TS2534: A function returning
2424
/** @type {FunctionReturningPromise} */
2525
async function testPromise2() {
2626
return "asd";
27-
~~~~~~~~~~~~~
27+
~~~~~~
2828
!!! error TS2322: Type 'string' is not assignable to type 'number'.
2929
}
3030

@@ -56,7 +56,7 @@ tests/cases/conformance/jsdoc/foo.js(45,18): error TS2534: A function returning
5656
/** @type {FunctionReturningNever} */
5757
async function testNever2() {
5858
return "asd";
59-
~~~~~~~~~~~~~
59+
~~~~~~
6060
!!! error TS2322: Type 'string' is not assignable to type 'never'.
6161
}
6262

tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tests/cases/compiler/bar.ts(4,31): error TS2523: 'yield' expressions cannot be u
99
}
1010

1111
export function* foo2({ foo = yield "a" }) {
12-
~~~~~~~~~
12+
~~~~~
1313
!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer.
1414
}
1515

tests/baselines/reference/generatorExplicitReturnType.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tests/cases/conformance/generators/generatorExplicitReturnType.ts(16,11): error
1717
~
1818
!!! error TS2322: Type 'string' is not assignable to type 'number'.
1919
return 10; // error
20-
~~~~~~~~~~
20+
~~~~~~
2121
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
2222
}
2323

tests/baselines/reference/generatorReturnContextualType.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tests/cases/conformance/generators/generatorReturnContextualType.ts(34,3): error
3636
async function* f4(): AsyncGenerator<any, { x: 'x' }, any> {
3737
const ret = { x: 'x' };
3838
return Promise.resolve(ret); // Error
39-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39+
~~~~~~
4040
!!! error TS2322: Type '{ x: string; }' is not assignable to type '{ x: "x"; }'.
4141
!!! error TS2322: Types of property 'x' are incompatible.
4242
!!! error TS2322: Type 'string' is not assignable to type '"x"'.
@@ -45,7 +45,7 @@ tests/cases/conformance/generators/generatorReturnContextualType.ts(34,3): error
4545
async function* g4(): AsyncIterator<any, { x: 'x' }, any> {
4646
const ret = { x: 'x' };
4747
return Promise.resolve(ret); // Error
48-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48+
~~~~~~
4949
!!! error TS2322: Type '{ x: string; }' is not assignable to type '{ x: "x"; }'.
5050
!!! error TS2322: Types of property 'x' are incompatible.
5151
!!! error TS2322: Type 'string' is not assignable to type '"x"'.

tests/baselines/reference/generatorReturnTypeInference.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ tests/cases/conformance/generators/generatorReturnTypeInference.ts(72,15): error
7474

7575
function* g204() { // Generator<number, void, any>
7676
const x = f2(yield 1);
77-
~~~~~~~
77+
~~~~~
7878
!!! error TS7057: 'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation.
7979
}
8080

tests/baselines/reference/generatorReturnTypeInferenceNonStrict.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ tests/cases/conformance/generators/generatorReturnTypeInferenceNonStrict.ts(131,
8686

8787
function* g204() { // Generator<number, void, any>
8888
const x = f2(yield 1);
89-
~~~~~~~
89+
~~~~~
9090
!!! error TS7057: 'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation.
9191
}
9292

tests/baselines/reference/getSetAccessorContextualTyping.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyp
1010
set X(x: number) { }
1111
get X() {
1212
return "string"; // Error; get contextual type by set accessor parameter type annotation
13-
~~~~~~~~~~~~~~~~
13+
~~~~~~
1414
!!! error TS2322: Type 'string' is not assignable to type 'number'.
1515
}
1616

tests/baselines/reference/importHelpersNoHelpersForAsyncGenerators.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ tests/cases/compiler/main.ts(4,5): error TS2343: This syntax requires an importe
1616
await 1;
1717
yield 2;
1818
yield* [3];
19-
~~~~~~~~~~
19+
~~~~~
2020
!!! error TS2343: This syntax requires an imported helper named '__asyncDelegator' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
21-
~~~~~~~~~~
21+
~~~~~
2222
!!! error TS2343: This syntax requires an imported helper named '__asyncValues' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
2323
}
2424

tests/baselines/reference/inferSetterParamType.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tests/cases/compiler/inferSetterParamType.ts(13,9): error TS2322: Type 'number'
1515

1616
get bar() {
1717
return 0; // should be an error - can't coerce infered return type to match setter annotated type
18-
~~~~~~~~~
18+
~~~~~~
1919
!!! error TS2322: Type 'number' is not assignable to type 'string'.
2020
}
2121
set bar(n:string) {

tests/baselines/reference/invalidReturnStatements.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(1
3131
name: string;
3232
}
3333
function fn10(): D { return { id: 12 }; }
34-
~~~~~~~~~~~~~~~~~~
34+
~~~~~~
3535
!!! error TS2739: Type '{ id: number; }' is missing the following properties from type 'D': name, dispose
3636

3737
function fn11(): D { return new C(); }
38-
~~~~~~~~~~~~~~~
38+
~~~~~~
3939
!!! error TS2741: Property 'name' is missing in type 'C' but required in type 'D'.
4040
!!! related TS2728 tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts:14:5: 'name' is declared here.
4141

tests/baselines/reference/keyofAndIndexedAccess2.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23
195195

196196
function get123<K extends keyof Type>(): Type[K] {
197197
return 123; // Error
198-
~~~~~~~~~~~
198+
~~~~~~
199199
!!! error TS2322: Type '123' is not assignable to type 'Type[K]'.
200200
!!! error TS2322: Type 'number' is not assignable to type 'never'.
201201
}

tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type
3232
else
3333
{
3434
return 12345;
35-
~~~~~~~~~~~~~
35+
~~~~~~
3636
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
3737
}
3838
}

tests/baselines/reference/narrowByEquality.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ tests/cases/compiler/narrowByEquality.ts(55,9): error TS2322: Type 'string | num
6666
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
6767
!!! error TS2322: Type 'string' is not assignable to type 'number'.
6868
return level;
69-
~~~~~~~~~~~~~
69+
~~~~~~
7070
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
7171
!!! error TS2322: Type 'string' is not assignable to type 'number'.
7272
}

0 commit comments

Comments
 (0)