diff --git a/.gitignore b/.gitignore index a6c8c2940d8..eb0df177040 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,5 @@ internal/ !tests/cases/projects/NodeModulesSearch/**/* !tests/baselines/reference/project/nodeModules*/**/* .idea -yarn.lock \ No newline at end of file +yarn.lock +package-lock.json diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bc2f859f8ec..3ac4e8e512d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6398,7 +6398,7 @@ namespace ts { undefined; // JS functions get a free rest parameter if they reference `arguments` let hasRestLikeParameter = hasRestParameter(declaration); - if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && !hasJSDocParameterTags(declaration) && containsArgumentsReference(declaration)) { + if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && containsArgumentsReference(declaration)) { hasRestLikeParameter = true; const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args"); syntheticArgsSymbol.type = anyArrayType; @@ -14500,7 +14500,7 @@ namespace ts { } function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined { - const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfObjectType(containingType), SymbolFlags.Value); + const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfType(containingType), SymbolFlags.Value); return suggestion && suggestion.name; } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 128acb1005d..1b7d54595e0 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -22,8 +22,7 @@ namespace RWC { } function isTsConfigFile(file: { path: string }): boolean { - const tsConfigFileName = "tsconfig.json"; - return file.path.substr(file.path.length - tsConfigFileName.length).toLowerCase() === tsConfigFileName; + return file.path.indexOf("tsconfig") !== -1 && file.path.indexOf("json") !== -1; } export function runRWCTest(jsonPath: string) { @@ -213,13 +212,13 @@ namespace RWC { it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => { - const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles( - inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory); - - if (declFileCompilationResult.declResult.errors.length === 0) { + if (compilerResult.errors.length === 0) { return null; } + const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles( + inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory); + return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); diff --git a/tests/baselines/reference/argumentsObjectCreatesRestForJs.types b/tests/baselines/reference/argumentsObjectCreatesRestForJs.types index 10596fb10c7..28cdfcda413 100644 --- a/tests/baselines/reference/argumentsObjectCreatesRestForJs.types +++ b/tests/baselines/reference/argumentsObjectCreatesRestForJs.types @@ -35,13 +35,13 @@ someRest(1, 2, 3); * @param {number} x - a thing */ function jsdocced(x) { arguments; } ->jsdocced : (x: number) => void +>jsdocced : (x: number, ...args: any[]) => void >x : number >arguments : IArguments jsdocced(1); >jsdocced(1) : void ->jsdocced : (x: number) => void +>jsdocced : (x: number, ...args: any[]) => void >1 : 1 function dontDoubleRest(x, ...y) { arguments; } diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt index d41d64c5a28..24be0fa24f4 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(44,1): error TS2554: Expected 2-4 arguments, but got 1. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(62,9): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(63,18): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(69,18): error TS2339: Property 'toFixed' does not exist on type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(69,18): error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'? ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts (6 errors) ==== @@ -87,7 +87,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio function fn5() { return undefined; } fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'. ~~~~~~~ -!!! error TS2339: Property 'toFixed' does not exist on type 'string'. +!!! error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'? fn5 `${ (n) => n.substr(0) }`; \ No newline at end of file diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt b/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt index 1e7a29c3378..78844382f61 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt +++ b/tests/baselines/reference/tsxStatelessFunctionComponents2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/jsx/file.tsx(19,16): error TS2559: Type '{ ref: "myRef"; }' has no properties in common with type 'IntrinsicAttributes & { name?: string; }'. -tests/cases/conformance/jsx/file.tsx(25,42): error TS2339: Property 'subtr' does not exist on type 'string'. +tests/cases/conformance/jsx/file.tsx(25,42): error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'? tests/cases/conformance/jsx/file.tsx(27,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'. tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'. @@ -33,7 +33,7 @@ tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNot // Error ('subtr' not on string) let e = x.greeting.subtr(10)} />; ~~~~~ -!!! error TS2339: Property 'subtr' does not exist on type 'string'. +!!! error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'? // Error (ref callback is contextually typed) let f = x.notARealProperty} />; ~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/unionPropertyExistence.errors.txt b/tests/baselines/reference/unionPropertyExistence.errors.txt index c13aa7d4d15..2ac1f2fafef 100644 --- a/tests/baselines/reference/unionPropertyExistence.errors.txt +++ b/tests/baselines/reference/unionPropertyExistence.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/unionPropertyExistence.ts(32,4): error TS2339: Property 'on Property 'onlyInB' does not exist on type 'A'. tests/cases/compiler/unionPropertyExistence.ts(35,5): error TS2339: Property 'notInC' does not exist on type 'ABC'. Property 'notInC' does not exist on type 'C'. -tests/cases/compiler/unionPropertyExistence.ts(36,4): error TS2339: Property 'notInB' does not exist on type 'AB'. +tests/cases/compiler/unionPropertyExistence.ts(36,4): error TS2551: Property 'notInB' does not exist on type 'AB'. Did you mean 'notInC'? Property 'notInB' does not exist on type 'B'. tests/cases/compiler/unionPropertyExistence.ts(37,5): error TS2339: Property 'notInB' does not exist on type 'ABC'. Property 'notInB' does not exist on type 'B'. @@ -69,8 +69,8 @@ tests/cases/compiler/unionPropertyExistence.ts(40,5): error TS2339: Property 'in !!! error TS2339: Property 'notInC' does not exist on type 'C'. ab.notInB; ~~~~~~ -!!! error TS2339: Property 'notInB' does not exist on type 'AB'. -!!! error TS2339: Property 'notInB' does not exist on type 'B'. +!!! error TS2551: Property 'notInB' does not exist on type 'AB'. Did you mean 'notInC'? +!!! error TS2551: Property 'notInB' does not exist on type 'B'. abc.notInB; ~~~~~~ !!! error TS2339: Property 'notInB' does not exist on type 'ABC'. diff --git a/tests/cases/fourslash/codeFixCorrectSpelling1.ts b/tests/cases/fourslash/codeFixCorrectSpelling1.ts new file mode 100644 index 00000000000..7f8739c80ae --- /dev/null +++ b/tests/cases/fourslash/codeFixCorrectSpelling1.ts @@ -0,0 +1,9 @@ +/// + +////[|function foo(s: string) { +//// return s.toStrang(); +////}|] + +verify.rangeAfterCodeFix(`function foo(s: string) { + return s.toString(); +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixCorrectSpelling2.ts b/tests/cases/fourslash/codeFixCorrectSpelling2.ts new file mode 100644 index 00000000000..b927eca0cad --- /dev/null +++ b/tests/cases/fourslash/codeFixCorrectSpelling2.ts @@ -0,0 +1,9 @@ +/// + +////[|function foo(x: T) { +//// return x.toStrang(); +////}|] + +verify.rangeAfterCodeFix(`function foo(x: T) { + return x.toString(); +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixCorrectSpelling3.ts b/tests/cases/fourslash/codeFixCorrectSpelling3.ts new file mode 100644 index 00000000000..4294e6e44df --- /dev/null +++ b/tests/cases/fourslash/codeFixCorrectSpelling3.ts @@ -0,0 +1,15 @@ +/// + +////[|class C { +//// state = 'hi' +//// doStuff() { +//// this.start; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + state = 'hi' + doStuff() { + this.state; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2);