Skip to content

Commit 171ab06

Browse files
authored
[Transforms] Merge master 06/14/2016 (#9169)
* Remove check narrowing only certain types, add test showing issues with this * string literal case test * Reconcile fix with CFA work * Defaultable -> NotNarrowable to align with use * Missed a defaultable in comments * Add test for narrowing to unions of string literals * Rewrite isInStringLiteral to accomodate for unterminated strings * Refactor signatureHelp to expose helper functions * Add support for completion in string literals * Remove unused check * Use const instead of let * Fix error * Formatting changes * Use shorthand properties * Add failing test for #8738 * Sort baseline reference identifier by name * Detects assignment to internal module export clause, fixes #8738 * add SharedArrayBuffer fix * Factor out assignment op check * Add test for composite assignment * Factor out the behaviour and handles x++ and ++x * Handles ES3 default as identifier name * Fix missing else statement * isNameOfExportedDeclarationInNonES6Module * Reorder options alphabetically * Mark diagnostics, and skipDefaultLibCheck as internal * Allow an import of "foo.js" to be matched by a file "foo.ts" * Improve loadModuleFromFile code * Respond to PR comments * Respond to more PR comments * Fix test * Actually merge from master * Revert to old tryLoad implementation * Run fixupParentReferences when parsing isolated jsDocComment * initial revision of unit test support for project system in tsserver * Allow wildcard ("*") patterns in ambient module declarations * Add non-widening forms of null and undefined * Create separate control flows for property declarations with initializers * Add regression test * Allow trailing commas in function parameter and argument lists * Add tests * Remove unused variable * Add null check and CR feedback * Support shorthand ambient module declarations * Revert "Merge pull request #7235 from weswigham/narrow-all-types" This reverts commit ef0f6c8, reversing changes made to 9f087cb. * reuse the fixupParentReferences function * Improve typing of && operator with --strictNullChecks * Add test * Respond to PR comments * Respond to PR comments * Add merging tests * Use a function `stringify` to simplify calls to `JSON.stringify(xyz, undefined, 2)` * Update tests * Fix mistake * Include indent in navigation bar protocol Previously navbar01 test had indents when run in the browser but not when run from node. Now they run the same. * Remove unnecessary restrictions in property access narrowing * Fix fourslash test * Add regression test * Consider property declarations to be control flow containers * Adding regression test * Remove restriction on --target es5 and --module es6 * change type definition for Object.create * Fix signature help * Add "implicit any" warning for shorthand ambient modules * Remove trailing whitespace * Support using string values in enums for CompilerOptions in transpile methods * Remove trailing whitespace in jakefile * Make `jake runtests-browser` support test regexes with spaces For example: `jake runtests-browser t="transpile .js files"` now works. * Add another test * factor out isJsxOrTsxExtension * Move to a conformance test * Revert "Revert "Merge pull request #7235 from weswigham/narrow-all-types"" This reverts commit fc3e040. * Use inclusive flag, as originally done, but include almost everything * Add additional tests * Respond to PR comments * Fix typo * add tests for tsserver project system * Fix test * Allow case comparison to undefined and null in strict null checking mode * Remove incorrectly added tests * check if moduleResolution when verifying that program can be reused * more tests for module resolution change and exclude * Fix linting issues * Merge JSDoc of assignments from function expressions * Allow nested assignments in type guards * Add tests * Improve order of parameter's merged jsdoc * Force LF newlines for LKG builds/non debug builds Fixes 6630 * Create intersection types in type guards for unrelated types * Split commentsFunction test into expr/decl And renumber. * Remove TODO comments * Accept new baselines * Add tests * Remove comments * Fix test helper * Recognize relative path using in outDir property (#9025) * Recognize relative path using in outDir property * Add projects tests * Add project .json files * Update baselines * Add comments * Add test case The test passes in 1.8 and fails in master. * Return trace when exception happens * Remove Long-Done TODO AFAIK, the harness sources have been concatenated into `run.js` for as long as I've known. This stops executing them twice (and in turn makes debugging tests much easier, since you no longer have to debug into eval'd code). * Allow primitive type guards with typeof on right Previously, only type guards of the form `typeof x === 'string'` were allowed. Now you can write `'string' === typeof x`. * Primitive type guards are now order independent * Fix comments in tests * Add handleing for classes * Add more tests for target=es5 module=es6 * addExportToArgumentListKind * Accept baseline * Add more tests * Adds progress indicators to the runtests-parallel build task. * Fixed typo * Fix comment * Add test for out-of-range error * Use proper method of not resolving alias * Fix module loading error (commandLineOptions_stringToEnum would be undefined if optionDeclarations wasn't loaded yet) * Update tests * Contextually type return statement in async function * Remove stale files * Undo change * Improve perf * Improve tests * Fix sourcemaps for debugging tests * Allow --sourceRoot with --inlineSources option Fixes #8445 * this in parameter initializers resolves to class Accept baselines now that the test passes. * Add tests for more kinds of import/export * Fix7334 Disallow async in functionExpression and ArrowFunction (#9062) * Error when using async modifier in function-expression and arrow-function when target es5 * Add tests and baselines * Resolve function-this in parameter initialisers when explicitly provided * Allow null/undefined guard with null/undefined on left Also add a test with baselines. * Code review comments * Update more diagnostic messages ES6->2015 Fix #8996 CC @mhegazy. * Fixes an issue with runtests-parallel when global mocha is not installed. * Update LKG * Add tests * fix baselines * Salsa: get members of variables whose initialisers are functions * Test adding members to JS variables whose initialisers are functions * Recommend runtests-parallel in CONTRIBUTING * Allow empty lists on command line * Remove single-comma empty array form * Remove trailing whitespace * Implicit type inclusion changes * Only inlineSourceMap when debugging through jake-browser (#9080) * Only inlineSourceMap when debugging through jake-browser * Address PR: fix typo in opt's property * minor fix: add missing return clause * Use camel-case instead of snake-case (#9134) * Baseline fix, CR comments, lint * CR changes * Add test for jsdoc in navigation bar * Fixes runtests-parallel not reporting failure for failed tests. * Fix decorator metadata emit for rest arg with no type * Add isDefinition to ReferenceEntry Clients can now easily tell if the reference is to a definition or a usage. * Test isDefinition * Add option to bail out of `jake runtests` when one test fails * Absolute-ify paths in both places * Refactor * Add unit test * lint * Added tests. * Accepted baselines. * Emit 'exports.' if the shorthand is a general export. * Accepted baselines. * Emit 'Promise' decorator metadata return type for async methods * Respond to PR comment * Unescape identifiers used in code completion * Make isDefinition required. For the deprecated getOccurrencesAtPosition, isDefinition is always false. * Add more isDefinition tests and fix computed property bug * Fix bug: do unescaping in the right place, so that it only affects escaped javascript identifiers * Use `isLiteralComputedPropertyDeclarationName`
1 parent f235bf7 commit 171ab06

File tree

145 files changed

+1359
-556
lines changed

Some content is hidden

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

145 files changed

+1359
-556
lines changed

Diff for: Jakefile.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -794,13 +794,14 @@ function runConsoleTests(defaultReporter, runInParallel) {
794794
colors = process.env.colors || process.env.color;
795795
colors = colors ? ' --no-colors ' : ' --colors ';
796796
reporter = process.env.reporter || process.env.r || defaultReporter;
797+
var bail = (process.env.bail || process.env.b) ? "--bail" : "";
797798
var lintFlag = process.env.lint !== 'false';
798799

799800
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
800801
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
801802
if(!runInParallel) {
802803
tests = tests ? ' -g "' + tests + '"' : '';
803-
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
804+
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run;
804805
console.log(cmd);
805806

806807
var savedNodeEnv = process.env.NODE_ENV;
@@ -865,7 +866,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
865866
runConsoleTests('min', /*runInParallel*/ true);
866867
}, {async: true});
867868

868-
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true dirty=false.");
869+
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true bail=false dirty=false.");
869870
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
870871
runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false);
871872
}, {async: true});

Diff for: scripts/mocha-parallel.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ function runTests(taskConfigsFolder, run, options, cb) {
193193
counter--;
194194

195195
if (counter <= 0) {
196-
var failed = 0;
197196
var reporter = new Base(),
198197
stats = reporter.stats,
199198
failures = reporter.failures;
@@ -224,8 +223,8 @@ function runTests(taskConfigsFolder, run, options, cb) {
224223
reporter.epilogue();
225224
}
226225

227-
if (failed) {
228-
return cb(new Error("Test failures reported: " + failed));
226+
if (stats.failures) {
227+
return cb(new Error("Test failures reported: " + stats.failures));
229228
}
230229
else {
231230
return cb();

Diff for: src/compiler/binder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ namespace ts {
19851985
classPrototype.parent = leftSideOfAssignment;
19861986

19871987
const funcSymbol = container.locals[constructorFunction.text];
1988-
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function)) {
1988+
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
19891989
return;
19901990
}
19911991

Diff for: src/compiler/checker.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -11497,8 +11497,12 @@ namespace ts {
1149711497
// When resolved signature is a call signature (and not a construct signature) the result type is any, unless
1149811498
// the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations
1149911499
// in a JS file
11500-
const funcSymbol = checkExpression(node.expression).symbol;
11501-
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) {
11500+
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
11501+
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
11502+
const funcSymbol = node.expression.kind === SyntaxKind.Identifier ?
11503+
getResolvedSymbol(node.expression as Identifier) :
11504+
checkExpression(node.expression).symbol;
11505+
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
1150211506
return getInferredClassType(funcSymbol);
1150311507
}
1150411508
else if (compilerOptions.noImplicitAny) {

Diff for: src/compiler/commandLineParser.ts

+23-8
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,13 @@ namespace ts {
342342
}
343343
},
344344
{
345-
name: "typesRoot",
346-
type: "string"
345+
name: "typeRoots",
346+
type: "list",
347+
element: {
348+
name: "typeRoots",
349+
type: "string",
350+
isFilePath: true
351+
}
347352
},
348353
{
349354
name: "types",
@@ -493,13 +498,20 @@ namespace ts {
493498
}
494499

495500
/* @internal */
496-
export function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] {
497-
const values = trimString((value || "")).split(",");
501+
export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Diagnostic[]): (string | number)[] | undefined {
502+
value = trimString(value);
503+
if (startsWith(value, "-")) {
504+
return undefined;
505+
}
506+
if (value === "") {
507+
return [];
508+
}
509+
const values = value.split(",");
498510
switch (opt.element.type) {
499511
case "number":
500-
return ts.map(values, parseInt);
512+
return map(values, parseInt);
501513
case "string":
502-
return ts.map(values, v => v || "");
514+
return map(values, v => v || "");
503515
default:
504516
return filter(map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v, errors)), v => !!v);
505517
}
@@ -560,8 +572,11 @@ namespace ts {
560572
i++;
561573
break;
562574
case "list":
563-
options[opt.name] = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
564-
i++;
575+
const result = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
576+
options[opt.name] = result || [];
577+
if (result) {
578+
i++;
579+
}
565580
break;
566581
// If not a primitive, the possible types are specified in what is effectively a map of options.
567582
default:

Diff for: src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,10 @@
19311931
"category": "Error",
19321932
"code": 2687
19331933
},
1934+
"Cannot find type definition file for '{0}'.": {
1935+
"category": "Error",
1936+
"code": 2688
1937+
},
19341938
"Import declaration '{0}' is using private name '{1}'.": {
19351939
"category": "Error",
19361940
"code": 4000

Diff for: src/compiler/program.ts

+50-54
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44

55
namespace ts {
66
/** The version of the TypeScript compiler release */
7+
export const version = "1.9.0";
78

89
const emptyArray: any[] = [];
910

10-
const defaultLibrarySearchPaths = [
11-
"types/",
12-
"node_modules/",
13-
"node_modules/@types/",
14-
];
15-
16-
export const version = "1.9.0";
11+
const defaultTypeRoots = ["node_modules/@types"];
1712

1813
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
1914
while (true) {
@@ -178,6 +173,11 @@ namespace ts {
178173

179174
const typeReferenceExtensions = [".d.ts"];
180175

176+
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
177+
return options.typeRoots ||
178+
defaultTypeRoots.map(d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d));
179+
}
180+
181181
/**
182182
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
183183
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
@@ -192,39 +192,36 @@ namespace ts {
192192
traceEnabled
193193
};
194194

195-
// use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set
196-
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
197-
195+
const typeRoots = getEffectiveTypeRoots(options, host);
198196
if (traceEnabled) {
199197
if (containingFile === undefined) {
200-
if (rootDir === undefined) {
198+
if (typeRoots === undefined) {
201199
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
202200
}
203201
else {
204-
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, rootDir);
202+
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
205203
}
206204
}
207205
else {
208-
if (rootDir === undefined) {
206+
if (typeRoots === undefined) {
209207
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
210208
}
211209
else {
212-
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, rootDir);
210+
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
213211
}
214212
}
215213
}
216214

217215
const failedLookupLocations: string[] = [];
218216

219217
// Check primary library paths
220-
if (rootDir !== undefined) {
221-
const effectivePrimarySearchPaths = options.typesSearchPaths || defaultLibrarySearchPaths;
222-
for (const searchPath of effectivePrimarySearchPaths) {
223-
const primaryPath = combinePaths(rootDir, searchPath);
224-
if (traceEnabled) {
225-
trace(host, Diagnostics.Resolving_with_primary_search_path_0, primaryPath);
226-
}
227-
const candidate = combinePaths(primaryPath, typeReferenceDirectiveName);
218+
if (typeRoots.length) {
219+
if (traceEnabled) {
220+
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
221+
}
222+
const primarySearchPaths = typeRoots;
223+
for (const typeRoot of primarySearchPaths) {
224+
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
228225
const candidateDirectory = getDirectoryPath(candidate);
229226
const resolvedFile = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations,
230227
!directoryProbablyExists(candidateDirectory, host), moduleResolutionState);
@@ -251,9 +248,6 @@ namespace ts {
251248
if (containingFile) {
252249
initialLocationForSecondaryLookup = getDirectoryPath(containingFile);
253250
}
254-
else {
255-
initialLocationForSecondaryLookup = rootDir;
256-
}
257251

258252
if (initialLocationForSecondaryLookup !== undefined) {
259253
// check secondary locations
@@ -932,19 +926,6 @@ namespace ts {
932926
}
933927
}
934928

935-
function getDefaultTypeDirectiveNames(rootPath: string): string[] {
936-
const localTypes = combinePaths(rootPath, "types");
937-
const npmTypes = combinePaths(rootPath, "node_modules/@types");
938-
let result: string[] = [];
939-
if (sys.directoryExists(localTypes)) {
940-
result = result.concat(sys.getDirectories(localTypes));
941-
}
942-
if (sys.directoryExists(npmTypes)) {
943-
result = result.concat(sys.getDirectories(npmTypes));
944-
}
945-
return result;
946-
}
947-
948929
function getDefaultLibLocation(): string {
949930
return getDirectoryPath(normalizePath(sys.getExecutingFilePath()));
950931
}
@@ -953,7 +934,6 @@ namespace ts {
953934
const realpath = sys.realpath && ((path: string) => sys.realpath(path));
954935

955936
return {
956-
getDefaultTypeDirectiveNames,
957937
getSourceFile,
958938
getDefaultLibLocation,
959939
getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)),
@@ -967,7 +947,8 @@ namespace ts {
967947
trace: (s: string) => sys.write(s + newLine),
968948
directoryExists: directoryName => sys.directoryExists(directoryName),
969949
realpath,
970-
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined)
950+
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined),
951+
getDirectories: (path: string) => sys.getDirectories(path),
971952
};
972953
}
973954

@@ -1030,21 +1011,35 @@ namespace ts {
10301011
return resolutions;
10311012
}
10321013

1033-
export function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
1014+
function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) {
1015+
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
1016+
}
1017+
1018+
/**
1019+
* Given a set of options and a set of root files, returns the set of type directive names
1020+
* that should be included for this program automatically.
1021+
* This list could either come from the config file,
1022+
* or from enumerating the types root + initial secondary types lookup location.
1023+
* More type directives might appear in the program later as a result of loading actual source files;
1024+
* this list is only the set of defaults that are implicitly included.
1025+
*/
1026+
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
10341027
// Use explicit type list from tsconfig.json
10351028
if (options.types) {
10361029
return options.types;
10371030
}
10381031

1039-
// or load all types from the automatic type import fields
1040-
if (host && host.getDefaultTypeDirectiveNames) {
1041-
const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
1042-
if (commonRoot) {
1043-
return host.getDefaultTypeDirectiveNames(commonRoot);
1032+
// Walk the primary type lookup locations
1033+
let result: string[] = [];
1034+
if (host.directoryExists && host.getDirectories) {
1035+
const typeRoots = getEffectiveTypeRoots(options, host);
1036+
for (const root of typeRoots) {
1037+
if (host.directoryExists(root)) {
1038+
result = result.concat(host.getDirectories(root));
1039+
}
10441040
}
10451041
}
1046-
1047-
return undefined;
1042+
return result;
10481043
}
10491044

10501045
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
@@ -1096,11 +1091,13 @@ namespace ts {
10961091
if (!tryReuseStructureFromOldProgram()) {
10971092
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
10981093

1099-
// load type declarations specified via 'types' argument
1100-
const typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host);
1094+
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
1095+
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host);
11011096

11021097
if (typeReferences) {
1103-
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
1098+
const inferredRoot = getInferredTypesRoot(options, rootNames, host);
1099+
const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts");
1100+
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
11041101
for (let i = 0; i < typeReferences.length; i++) {
11051102
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
11061103
}
@@ -1208,10 +1205,9 @@ namespace ts {
12081205
(oldOptions.jsx !== options.jsx) ||
12091206
(oldOptions.allowJs !== options.allowJs) ||
12101207
(oldOptions.rootDir !== options.rootDir) ||
1211-
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
12121208
(oldOptions.configFilePath !== options.configFilePath) ||
12131209
(oldOptions.baseUrl !== options.baseUrl) ||
1214-
(oldOptions.typesRoot !== options.typesRoot) ||
1210+
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
12151211
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
12161212
!mapIsEqualTo(oldOptions.paths, options.paths)) {
12171213
return false;
@@ -1967,7 +1963,7 @@ namespace ts {
19671963
}
19681964
}
19691965
else {
1970-
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_name_0, typeReferenceDirective));
1966+
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
19711967
}
19721968

19731969
if (saveResolution) {

Diff for: src/compiler/types.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2630,9 +2630,9 @@ namespace ts {
26302630
target?: ScriptTarget;
26312631
traceResolution?: boolean;
26322632
types?: string[];
2633-
/* @internal */ typesRoot?: string;
2633+
/** Paths used to used to compute primary types search locations */
2634+
typeRoots?: string[];
26342635
typesSearchPaths?: string[];
2635-
/* @internal */ useLegacyEmitter?: boolean;
26362636
/*@internal*/ version?: boolean;
26372637
/*@internal*/ watch?: boolean;
26382638

@@ -2940,6 +2940,7 @@ namespace ts {
29402940
getDefaultTypeDirectiveNames?(rootPath: string): string[];
29412941
writeFile: WriteFileCallback;
29422942
getCurrentDirectory(): string;
2943+
getDirectories(path: string): string[];
29432944
getCanonicalFileName(fileName: string): string;
29442945
useCaseSensitiveFileNames(): boolean;
29452946
getNewLine(): string;

Diff for: src/compiler/utilities.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,18 @@ namespace ts {
13621362
return charCode === CharacterCodes.singleQuote || charCode === CharacterCodes.doubleQuote;
13631363
}
13641364

1365+
/**
1366+
* Returns true if the node is a variable declaration whose initializer is a function expression.
1367+
* This function does not test if the node is in a JavaScript file or not.
1368+
*/
1369+
export function isDeclarationOfFunctionExpression(s: Symbol) {
1370+
if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) {
1371+
const declaration = s.valueDeclaration as VariableDeclaration;
1372+
return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression;
1373+
}
1374+
return false;
1375+
}
1376+
13651377
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
13661378
/// assignments we treat as special in the binder
13671379
export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind {

0 commit comments

Comments
 (0)