Skip to content

Commit e8ac1ab

Browse files
committed
Baseline fix, CR comments, lint
1 parent 576f09f commit e8ac1ab

File tree

9 files changed

+51
-30
lines changed

9 files changed

+51
-30
lines changed

src/compiler/commandLineParser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ namespace ts {
341341
type: "list",
342342
element: {
343343
name: "typeRoots",
344-
type: "string"
345-
}
344+
type: "string",
345+
isFilePath: true
346+
}
346347
},
347348
{
348349
name: "types",

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ namespace ts {
217217
// Check primary library paths
218218
if (typeRoots.length) {
219219
if (traceEnabled) {
220-
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(', '));
220+
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
221221
}
222-
const primarySearchPaths = options.typeRoots || defaultTypeRoots;
222+
const primarySearchPaths = typeRoots;
223223
for (const typeRoot of primarySearchPaths) {
224224
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
225225
const candidateDirectory = getDirectoryPath(candidate);

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ namespace ts {
25622562
target?: ScriptTarget;
25632563
traceResolution?: boolean;
25642564
types?: string[];
2565-
// Paths used to used to compute primary types search locations
2565+
/** Paths used to used to compute primary types search locations */
25662566
typeRoots?: string[];
25672567
typesSearchPaths?: string[];
25682568
/*@internal*/ version?: boolean;

src/server/editorServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ namespace ts.server {
316316
}
317317

318318
getDirectories(path: string): string[] {
319-
return this.host.getDirectories ? this.host.getDirectories(path) : [];
319+
return this.host.getDirectories(path);
320320
}
321321

322322
/**

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ namespace ts {
21412141
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
21422142

21432143
function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey {
2144-
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${settings.typeRoots}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
2144+
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${JSON.stringify(settings.typeRoots)}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
21452145
}
21462146

21472147
function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== /src/foo.ts ===
2+
/// <reference types="alpha" />
3+
var x: string = alpha.a;
4+
>x : Symbol(x, Decl(foo.ts, 1, 3))
5+
>alpha.a : Symbol(a, Decl(index.d.ts, 3, 20))
6+
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
7+
>a : Symbol(a, Decl(index.d.ts, 3, 20))
8+
9+
=== /node_modules/@types/alpha/index.d.ts ===
10+
11+
// The primary lookup folder is relative to tsconfig.json, if present
12+
13+
declare var alpha: { a: string };
14+
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
15+
>a : Symbol(a, Decl(index.d.ts, 3, 20))
16+

tests/baselines/reference/library-reference-6.trace.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,11 @@
22
"======== Resolving type reference directive 'alpha', containing file '/src/foo.ts', root directory 'node_modules/@types'. ========",
33
"Resolving with primary search path 'node_modules/@types'",
44
"File 'node_modules/@types/alpha/package.json' does not exist.",
5-
"File 'node_modules/@types/alpha/index.d.ts' does not exist.",
6-
"Looking up in 'node_modules' folder, initial location '/src'",
7-
"File '/src/node_modules/alpha.ts' does not exist.",
8-
"File '/src/node_modules/alpha.d.ts' does not exist.",
9-
"File '/src/node_modules/alpha/package.json' does not exist.",
10-
"File '/src/node_modules/alpha/index.ts' does not exist.",
11-
"File '/src/node_modules/alpha/index.d.ts' does not exist.",
12-
"File '/src/node_modules/@types/alpha.ts' does not exist.",
13-
"File '/src/node_modules/@types/alpha.d.ts' does not exist.",
14-
"File '/src/node_modules/@types/alpha/package.json' does not exist.",
15-
"File '/src/node_modules/@types/alpha/index.ts' does not exist.",
16-
"File '/src/node_modules/@types/alpha/index.d.ts' does not exist.",
17-
"File '/node_modules/alpha.ts' does not exist.",
18-
"File '/node_modules/alpha.d.ts' does not exist.",
19-
"File '/node_modules/alpha/package.json' does not exist.",
20-
"File '/node_modules/alpha/index.ts' does not exist.",
21-
"File '/node_modules/alpha/index.d.ts' does not exist.",
22-
"File '/node_modules/@types/alpha.ts' does not exist.",
23-
"File '/node_modules/@types/alpha.d.ts' does not exist.",
24-
"File '/node_modules/@types/alpha/package.json' does not exist.",
25-
"File '/node_modules/@types/alpha/index.ts' does not exist.",
26-
"File '/node_modules/@types/alpha/index.d.ts' does not exist.",
27-
"======== Type reference directive 'alpha' was not resolved. ========"
5+
"File 'node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
6+
"======== Type reference directive 'alpha' was successfully resolved to 'node_modules/@types/alpha/index.d.ts', primary: true. ========",
7+
"======== Resolving type reference directive 'alpha', containing file '/src/__inferred type names__.ts', root directory 'node_modules/@types'. ========",
8+
"Resolving with primary search path 'node_modules/@types'",
9+
"File 'node_modules/@types/alpha/package.json' does not exist.",
10+
"File 'node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
11+
"======== Type reference directive 'alpha' was successfully resolved to 'node_modules/@types/alpha/index.d.ts', primary: true. ========"
2812
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== /src/foo.ts ===
2+
/// <reference types="alpha" />
3+
var x: string = alpha.a;
4+
>x : string
5+
>alpha.a : string
6+
>alpha : { a: string; }
7+
>a : string
8+
9+
=== /node_modules/@types/alpha/index.d.ts ===
10+
11+
// The primary lookup folder is relative to tsconfig.json, if present
12+
13+
declare var alpha: { a: string };
14+
>alpha : { a: string; }
15+
>a : string
16+

tests/baselines/reference/moduleResolutionWithExtensions.trace.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"Module resolution kind is not specified, using 'NodeJs'.",
44
"Loading module as file / folder, candidate module location '/src/a'.",
55
"File '/src/a.ts' exist - use it as a name resolution result.",
6+
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
67
"======== Module name './a' was successfully resolved to '/src/a.ts'. ========",
78
"======== Resolving module './a.ts' from '/src/c.ts'. ========",
89
"Module resolution kind is not specified, using 'NodeJs'.",
910
"Loading module as file / folder, candidate module location '/src/a.ts'.",
1011
"File '/src/a.ts' exist - use it as a name resolution result.",
12+
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
1113
"======== Module name './a.ts' was successfully resolved to '/src/a.ts'. ========",
1214
"======== Resolving module './a.js' from '/src/d.ts'. ========",
1315
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -17,6 +19,7 @@
1719
"File '/src/a.js.d.ts' does not exist.",
1820
"File name '/src/a.js' has a '.js' extension - stripping it",
1921
"File '/src/a.ts' exist - use it as a name resolution result.",
22+
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
2023
"======== Module name './a.js' was successfully resolved to '/src/a.ts'. ========",
2124
"======== Resolving module './jquery.js' from '/src/jquery_user_1.ts'. ========",
2225
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -28,5 +31,6 @@
2831
"File '/src/jquery.ts' does not exist.",
2932
"File '/src/jquery.tsx' does not exist.",
3033
"File '/src/jquery.d.ts' exist - use it as a name resolution result.",
34+
"Resolving real path for '/src/jquery.d.ts', result '/src/jquery.d.ts'",
3135
"======== Module name './jquery.js' was successfully resolved to '/src/jquery.d.ts'. ========"
3236
]

0 commit comments

Comments
 (0)