Skip to content

Commit dc08c5f

Browse files
committed
Merge branch 'master' into caretPositionInFourslash
2 parents 86894f3 + 296660a commit dc08c5f

10 files changed

Lines changed: 51 additions & 18 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ internal/
5757
!tests/cases/projects/NodeModulesSearch/**/*
5858
!tests/baselines/reference/project/nodeModules*/**/*
5959
.idea
60-
yarn.lock
60+
yarn.lock
61+
package-lock.json

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6398,7 +6398,7 @@ namespace ts {
63986398
undefined;
63996399
// JS functions get a free rest parameter if they reference `arguments`
64006400
let hasRestLikeParameter = hasRestParameter(declaration);
6401-
if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && !hasJSDocParameterTags(declaration) && containsArgumentsReference(declaration)) {
6401+
if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && containsArgumentsReference(declaration)) {
64026402
hasRestLikeParameter = true;
64036403
const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args");
64046404
syntheticArgsSymbol.type = anyArrayType;
@@ -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

src/harness/rwcRunner.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ namespace RWC {
2222
}
2323

2424
function isTsConfigFile(file: { path: string }): boolean {
25-
const tsConfigFileName = "tsconfig.json";
26-
return file.path.substr(file.path.length - tsConfigFileName.length).toLowerCase() === tsConfigFileName;
25+
return file.path.indexOf("tsconfig") !== -1 && file.path.indexOf("json") !== -1;
2726
}
2827

2928
export function runRWCTest(jsonPath: string) {
@@ -213,13 +212,13 @@ namespace RWC {
213212
it("has the expected errors in generated declaration files", () => {
214213
if (compilerOptions.declaration && !compilerResult.errors.length) {
215214
Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => {
216-
const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(
217-
inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory);
218-
219-
if (declFileCompilationResult.declResult.errors.length === 0) {
215+
if (compilerResult.errors.length === 0) {
220216
return null;
221217
}
222218

219+
const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(
220+
inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory);
221+
223222
return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) +
224223
Harness.IO.newLine() + Harness.IO.newLine() +
225224
Harness.Compiler.getErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors);

tests/baselines/reference/argumentsObjectCreatesRestForJs.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ someRest(1, 2, 3);
3535
* @param {number} x - a thing
3636
*/
3737
function jsdocced(x) { arguments; }
38-
>jsdocced : (x: number) => void
38+
>jsdocced : (x: number, ...args: any[]) => void
3939
>x : number
4040
>arguments : IArguments
4141

4242
jsdocced(1);
4343
>jsdocced(1) : void
44-
>jsdocced : (x: number) => void
44+
>jsdocced : (x: number, ...args: any[]) => void
4545
>1 : 1
4646

4747
function dontDoubleRest(x, ...y) { arguments; }

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)