Skip to content

Commit 0257ace

Browse files
committed
Respond to code review comments
1 parent fe96258 commit 0257ace

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ module ts {
633633
}
634634
}
635635

636-
export function getDefaultLibraryFilename(options: CompilerOptions): string {
636+
export function getDefaultLibFilename(options: CompilerOptions): string {
637637
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
638638
}
639639

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module ts {
6464

6565
return {
6666
getSourceFile,
67-
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibraryFilename(options)),
67+
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFilename(options)),
6868
writeFile,
6969
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
7070
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,

src/services/services.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,12 +2045,12 @@ module ts {
20452045

20462046
// Now create a new compiler
20472047
program = createProgram(hostfilenames, compilationSettings, {
2048-
getSourceFile: getSourceFile,
2048+
getSourceFile,
20492049
getCancellationToken: () => cancellationToken,
20502050
getCanonicalFileName: filename => useCaseSensitivefilenames ? filename : filename.toLowerCase(),
20512051
useCaseSensitiveFileNames: () => useCaseSensitivefilenames,
20522052
getNewLine: () => host.getNewLine ? host.getNewLine() : "\r\n",
2053-
getDefaultLibFilename: getDefaultLibraryFilename,
2053+
getDefaultLibFilename,
20542054
writeFile: (filename, data, writeByteOrderMark) => { },
20552055
getCurrentDirectory: () => host.getCurrentDirectory()
20562056
});
@@ -5698,16 +5698,16 @@ module ts {
56985698

56995699
/// getDefaultLibraryFilePath
57005700
declare var __dirname: string;
5701-
declare var module: any;
5702-
5701+
57035702
/**
57045703
* Get the path of the default library file (lib.d.ts) as distributed with the typescript
57055704
* node package.
57065705
* The functionality is not supported if the ts module is consumed outside of a node module.
57075706
*/
57085707
export function getDefaultLibraryFilePath(options: CompilerOptions): string {
5709-
if (typeof module !== "undefined" && module.exports) {
5710-
return __dirname + directorySeparator + getDefaultLibraryFilename(options);
5708+
// Check __dirname is defined and that we are on a node.js system.
5709+
if (typeof __dirname !== "undefined") {
5710+
return __dirname + directorySeparator + getDefaultLibFilename(options);
57115711
}
57125712

57135713
throw new Error("getDefaultLibraryFilename is only supported when consumed as a node module. ");

tests/cases/unittests/services/documentRegistry.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ describe("DocumentRegistry", () => {
55
var documentRegistry = ts.createDocumentRegistry();
66
var defaultCompilerOptions = ts.getDefaultCompilerOptions();
77

8-
var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), "1");
9-
var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), "1");
8+
var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1");
9+
var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1");
1010

1111
assert(f1 === f2, "DocumentRegistry should return the same document for the same name");
1212
});
@@ -17,21 +17,21 @@ describe("DocumentRegistry", () => {
1717

1818
// change compilation setting that doesn't affect parsing - should have the same document
1919
compilerOptions.declaration = true;
20-
var f1 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), "1");
20+
var f1 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1");
2121
compilerOptions.declaration = false;
22-
var f2 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), "1");
22+
var f2 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1");
2323

2424
assert(f1 === f2, "Expected to have the same document instance");
2525

2626

2727
// change value of compilation setting that is used during production of AST - new document is required
2828
compilerOptions.target = ts.ScriptTarget.ES3;
29-
var f3 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), "1");
29+
var f3 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1");
3030

3131
assert(f1 !== f3, "Changed target: Expected to have different instances of document");
3232

3333
compilerOptions.module = ts.ModuleKind.CommonJS;
34-
var f4 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), "1");
34+
var f4 = documentRegistry.acquireDocument("file1.ts", compilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1");
3535

3636
assert(f3 === f4, "Changed module: Expected to have the same instance of the document");
3737
});

0 commit comments

Comments
 (0)