Merge pull request #10340 from Microsoft/lower_case_types
Use lowercase names for type reference directives
This commit is contained in:
commit
ef4fefc197
6 changed files with 67 additions and 3 deletions
|
@ -2010,15 +2010,16 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function processTypeReferenceDirectives(file: SourceFile) {
|
function processTypeReferenceDirectives(file: SourceFile) {
|
||||||
const typeDirectives = map(file.typeReferenceDirectives, l => l.fileName);
|
const typeDirectives = map(file.typeReferenceDirectives, ref => ref.fileName.toLocaleLowerCase());
|
||||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName);
|
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName);
|
||||||
|
|
||||||
for (let i = 0; i < typeDirectives.length; i++) {
|
for (let i = 0; i < typeDirectives.length; i++) {
|
||||||
const ref = file.typeReferenceDirectives[i];
|
const ref = file.typeReferenceDirectives[i];
|
||||||
const resolvedTypeReferenceDirective = resolutions[i];
|
const resolvedTypeReferenceDirective = resolutions[i];
|
||||||
// store resolved type directive on the file
|
// store resolved type directive on the file
|
||||||
setResolvedTypeReferenceDirective(file, ref.fileName, resolvedTypeReferenceDirective);
|
const fileName = ref.fileName.toLocaleLowerCase();
|
||||||
processTypeReferenceDirective(ref.fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end);
|
setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
||||||
|
processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
tests/baselines/reference/typingsLookup3.js
Normal file
13
tests/baselines/reference/typingsLookup3.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//// [tests/cases/conformance/typings/typingsLookup3.ts] ////
|
||||||
|
|
||||||
|
//// [index.d.ts]
|
||||||
|
declare var $: { x: any };
|
||||||
|
|
||||||
|
//// [a.ts]
|
||||||
|
/// <reference types="JqUeRy" />
|
||||||
|
$.x;
|
||||||
|
|
||||||
|
|
||||||
|
//// [a.js]
|
||||||
|
/// <reference types="JqUeRy" />
|
||||||
|
$.x;
|
12
tests/baselines/reference/typingsLookup3.symbols
Normal file
12
tests/baselines/reference/typingsLookup3.symbols
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
=== /a.ts ===
|
||||||
|
/// <reference types="JqUeRy" />
|
||||||
|
$.x;
|
||||||
|
>$.x : Symbol(x, Decl(index.d.ts, 0, 16))
|
||||||
|
>$ : Symbol($, Decl(index.d.ts, 0, 11))
|
||||||
|
>x : Symbol(x, Decl(index.d.ts, 0, 16))
|
||||||
|
|
||||||
|
=== /node_modules/@types/jquery/index.d.ts ===
|
||||||
|
declare var $: { x: any };
|
||||||
|
>$ : Symbol($, Decl(index.d.ts, 0, 11))
|
||||||
|
>x : Symbol(x, Decl(index.d.ts, 0, 16))
|
||||||
|
|
12
tests/baselines/reference/typingsLookup3.trace.json
Normal file
12
tests/baselines/reference/typingsLookup3.trace.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[
|
||||||
|
"======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========",
|
||||||
|
"Resolving with primary search path '/node_modules/@types'",
|
||||||
|
"File '/node_modules/@types/jquery/package.json' does not exist.",
|
||||||
|
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||||
|
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========",
|
||||||
|
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
|
||||||
|
"Resolving with primary search path '/node_modules/@types'",
|
||||||
|
"File '/node_modules/@types/jquery/package.json' does not exist.",
|
||||||
|
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||||
|
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========"
|
||||||
|
]
|
12
tests/baselines/reference/typingsLookup3.types
Normal file
12
tests/baselines/reference/typingsLookup3.types
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
=== /a.ts ===
|
||||||
|
/// <reference types="JqUeRy" />
|
||||||
|
$.x;
|
||||||
|
>$.x : any
|
||||||
|
>$ : { x: any; }
|
||||||
|
>x : any
|
||||||
|
|
||||||
|
=== /node_modules/@types/jquery/index.d.ts ===
|
||||||
|
declare var $: { x: any };
|
||||||
|
>$ : { x: any; }
|
||||||
|
>x : any
|
||||||
|
|
14
tests/cases/conformance/typings/typingsLookup3.ts
Normal file
14
tests/cases/conformance/typings/typingsLookup3.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// @traceResolution: true
|
||||||
|
// @noImplicitReferences: true
|
||||||
|
// @currentDirectory: /
|
||||||
|
// This tests that `types` references are automatically lowercased.
|
||||||
|
|
||||||
|
// @filename: /tsconfig.json
|
||||||
|
{ "files": "a.ts" }
|
||||||
|
|
||||||
|
// @filename: /node_modules/@types/jquery/index.d.ts
|
||||||
|
declare var $: { x: any };
|
||||||
|
|
||||||
|
// @filename: /a.ts
|
||||||
|
/// <reference types="JqUeRy" />
|
||||||
|
$.x;
|
Loading…
Reference in a new issue