Skip to content

Commit 9048c0a

Browse files
authored
Merge pull request microsoft#16844 from Microsoft/codefix-spelling-correction-for-typeparameters
Spelling code fix: suggestions from apparent type
2 parents a7fe9db + abec46c commit 9048c0a

7 files changed

+41
-8
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14500,7 +14500,7 @@ namespace ts {
1450014500
}
1450114501

1450214502
function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined {
14503-
const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfObjectType(containingType), SymbolFlags.Value);
14503+
const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfType(containingType), SymbolFlags.Value);
1450414504
return suggestion && suggestion.name;
1450514505
}
1450614506

tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
33
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(44,1): error TS2554: Expected 2-4 arguments, but got 1.
44
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(62,9): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'.
55
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(63,18): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'.
6-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(69,18): error TS2339: Property 'toFixed' does not exist on type 'string'.
6+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(69,18): error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'?
77

88

99
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts (6 errors) ====
@@ -87,7 +87,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
8787
function fn5() { return undefined; }
8888
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
8989
~~~~~~~
90-
!!! error TS2339: Property 'toFixed' does not exist on type 'string'.
90+
!!! error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'?
9191
fn5 `${ (n) => n.substr(0) }`;
9292

9393

tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/jsx/file.tsx(19,16): error TS2559: Type '{ ref: "myRef"; }' has no properties in common with type 'IntrinsicAttributes & { name?: string; }'.
2-
tests/cases/conformance/jsx/file.tsx(25,42): error TS2339: Property 'subtr' does not exist on type 'string'.
2+
tests/cases/conformance/jsx/file.tsx(25,42): error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'?
33
tests/cases/conformance/jsx/file.tsx(27,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
44
tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.
55

@@ -33,7 +33,7 @@ tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNot
3333
// Error ('subtr' not on string)
3434
let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
3535
~~~~~
36-
!!! error TS2339: Property 'subtr' does not exist on type 'string'.
36+
!!! error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'?
3737
// Error (ref callback is contextually typed)
3838
let f = <BigGreeter ref={x => x.notARealProperty} />;
3939
~~~~~~~~~~~~~~~~

tests/baselines/reference/unionPropertyExistence.errors.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tests/cases/compiler/unionPropertyExistence.ts(32,4): error TS2339: Property 'on
88
Property 'onlyInB' does not exist on type 'A'.
99
tests/cases/compiler/unionPropertyExistence.ts(35,5): error TS2339: Property 'notInC' does not exist on type 'ABC'.
1010
Property 'notInC' does not exist on type 'C'.
11-
tests/cases/compiler/unionPropertyExistence.ts(36,4): error TS2339: Property 'notInB' does not exist on type 'AB'.
11+
tests/cases/compiler/unionPropertyExistence.ts(36,4): error TS2551: Property 'notInB' does not exist on type 'AB'. Did you mean 'notInC'?
1212
Property 'notInB' does not exist on type 'B'.
1313
tests/cases/compiler/unionPropertyExistence.ts(37,5): error TS2339: Property 'notInB' does not exist on type 'ABC'.
1414
Property 'notInB' does not exist on type 'B'.
@@ -69,8 +69,8 @@ tests/cases/compiler/unionPropertyExistence.ts(40,5): error TS2339: Property 'in
6969
!!! error TS2339: Property 'notInC' does not exist on type 'C'.
7070
ab.notInB;
7171
~~~~~~
72-
!!! error TS2339: Property 'notInB' does not exist on type 'AB'.
73-
!!! error TS2339: Property 'notInB' does not exist on type 'B'.
72+
!!! error TS2551: Property 'notInB' does not exist on type 'AB'. Did you mean 'notInC'?
73+
!!! error TS2551: Property 'notInB' does not exist on type 'B'.
7474
abc.notInB;
7575
~~~~~~
7676
!!! error TS2339: Property 'notInB' does not exist on type 'ABC'.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////[|function foo(s: string) {
4+
//// return s.toStrang();
5+
////}|]
6+
7+
verify.rangeAfterCodeFix(`function foo(s: string) {
8+
return s.toString();
9+
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////[|function foo<T extends number | string>(x: T) {
4+
//// return x.toStrang();
5+
////}|]
6+
7+
verify.rangeAfterCodeFix(`function foo<T extends number | string>(x: T) {
8+
return x.toString();
9+
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////[|class C {
4+
//// state = 'hi'
5+
//// doStuff() {
6+
//// this.start;
7+
//// }
8+
////}|]
9+
10+
verify.rangeAfterCodeFix(`class C {
11+
state = 'hi'
12+
doStuff() {
13+
this.state;
14+
}
15+
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2);

0 commit comments

Comments
 (0)