Skip to content

Commit

Permalink
2016-09-03 [ci skip] Version: 1.201609030106.1+32b6746afe193bfa0cd077…
Browse files Browse the repository at this point in the history
…98768134f1b8963fe1
  • Loading branch information
basarat committed Sep 3, 2016
1 parent a080ee9 commit 05c4dbf
Show file tree
Hide file tree
Showing 13 changed files with 3,948 additions and 3,820 deletions.
2 changes: 1 addition & 1 deletion TypeScript
Submodule TypeScript updated 105 files
2,189 changes: 1,098 additions & 1,091 deletions bin/ntypescript.d.ts

Large diffs are not rendered by default.

857 changes: 447 additions & 410 deletions bin/ntypescript.js

Large diffs are not rendered by default.

2,189 changes: 1,098 additions & 1,091 deletions bin/typescript.d.ts

Large diffs are not rendered by default.

857 changes: 447 additions & 410 deletions bin/typescript.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kicktravis
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2016-09-02 [ci skip] Version: 1.201609020105.1+8038eb943e6509a5da3377853ca04986bededbb1
2016-09-03 [ci skip] Version: 1.201609030106.1+32b6746afe193bfa0cd07798768134f1b8963fe1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ntypescript",
"version": "1.201609020105.1+8038eb943e6509a5da3377853ca04986bededbb1",
"version": "1.201609030106.1+32b6746afe193bfa0cd07798768134f1b8963fe1",
"description": "A nicer version of microsoft/typescript packaged and released for API developers",
"main": "./bin/ntypescript.js",
"bin": {
Expand Down
15 changes: 15 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,21 @@ namespace ts {
return result;
}

/**
* Adds the value to an array of values associated with the key, and returns the array.
* Creates the array if it does not already exist.
*/
export function multiMapAdd<V>(map: Map<V[]>, key: string, value: V): V[] {
const values = map[key];
if (values) {
values.push(value);
return values;
}
else {
return map[key] = [value];
}
}

/**
* Tests whether a value is an array.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6851,7 +6851,7 @@ const _super = (function (geti, seti) {
// export { x, y }
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
const name = (specifier.propertyName || specifier.name).text;
(exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier);
multiMapAdd(exportSpecifiers, name, specifier);
}
}
break;
Expand Down
36 changes: 30 additions & 6 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace ts {

const emptyArray: any[] = [];

const defaultTypeRoots = ["node_modules/@types"];

export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
while (true) {
const fileName = combinePaths(searchPath, "tsconfig.json");
Expand Down Expand Up @@ -168,7 +166,7 @@ namespace ts {

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

function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost): string[] | undefined {
if (options.typeRoots) {
return options.typeRoots;
}
Expand All @@ -181,11 +179,37 @@ namespace ts {
currentDirectory = host.getCurrentDirectory();
}

if (!currentDirectory) {
return undefined;
return currentDirectory && getDefaultTypeRoots(currentDirectory, host);
}

/**
* Returns the path to every node_modules/@types directory from some ancestor directory.
* Returns undefined if there are none.
*/
function getDefaultTypeRoots(currentDirectory: string, host: ModuleResolutionHost): string[] | undefined {
if (!host.directoryExists) {
return [combinePaths(currentDirectory, "node_modules")];
// And if it doesn't exist, tough.
}
return map(defaultTypeRoots, d => combinePaths(currentDirectory, d));

let typeRoots: string[];

while (true) {
const atTypes = combinePaths(currentDirectory, nodeModulesAtTypes);
if (host.directoryExists(atTypes)) {
(typeRoots || (typeRoots = [])).push(atTypes);
}

const parent = getDirectoryPath(currentDirectory);
if (parent === currentDirectory) {
break;
}
currentDirectory = parent;
}

return typeRoots;
}
const nodeModulesAtTypes = combinePaths("node_modules", "@types");

/**
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ namespace ts {
}

function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void {
(fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback);
multiMapAdd(fileWatcherCallbacks, filePath, callback);
}

function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile {
Expand Down
Loading

0 comments on commit 05c4dbf

Please sign in to comment.