Merge branch 'master' into caretPositionInFourslash

This commit is contained in:
Arthur Ozga 2017-07-06 10:44:59 -07:00
commit dc08c5f241
10 changed files with 51 additions and 18 deletions

3
.gitignore vendored
View File

@ -57,4 +57,5 @@ internal/
!tests/cases/projects/NodeModulesSearch/**/*
!tests/baselines/reference/project/nodeModules*/**/*
.idea
yarn.lock
yarn.lock
package-lock.json

View File

@ -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;
}

View File

@ -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);

View File

@ -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; }

View File

@ -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) }`;

View File

@ -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 = <BigGreeter ref={x => 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 = <BigGreeter ref={x => x.notARealProperty} />;
~~~~~~~~~~~~~~~~

View File

@ -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'.

View File

@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
////[|function foo(s: string) {
//// return s.toStrang();
////}|]
verify.rangeAfterCodeFix(`function foo(s: string) {
return s.toString();
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
////[|function foo<T extends number | string>(x: T) {
//// return x.toStrang();
////}|]
verify.rangeAfterCodeFix(`function foo<T extends number | string>(x: T) {
return x.toString();
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);

View File

@ -0,0 +1,15 @@
/// <reference path='fourslash.ts' />
////[|class C {
//// state = 'hi'
//// doStuff() {
//// this.start;
//// }
////}|]
verify.rangeAfterCodeFix(`class C {
state = 'hi'
doStuff() {
this.state;
}
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2);