Skip to content

Use lowercase names for type reference directives #10340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2012,15 +2012,16 @@ namespace ts {
}

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);

for (let i = 0; i < typeDirectives.length; i++) {
const ref = file.typeReferenceDirectives[i];
const resolvedTypeReferenceDirective = resolutions[i];
// store resolved type directive on the file
setResolvedTypeReferenceDirective(file, ref.fileName, resolvedTypeReferenceDirective);
processTypeReferenceDirective(ref.fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end);
const fileName = ref.fileName.toLocaleLowerCase();
setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end);
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/baselines/reference/typingsLookup3.js
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions tests/baselines/reference/typingsLookup3.symbols
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions tests/baselines/reference/typingsLookup3.trace.json
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions tests/baselines/reference/typingsLookup3.types
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions tests/cases/conformance/typings/typingsLookup3.ts
Original file line number Diff line number Diff line change
@@ -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;