Skip to content

Commit 65a2458

Browse files
committed
Library references WIP
1 parent ca179cf commit 65a2458

14 files changed

+259
-1
lines changed

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ namespace ts {
697697
let program: Program;
698698
let files: SourceFile[] = [];
699699
let fileProcessingDiagnostics = createDiagnosticCollection();
700+
const currentDirectory = host.getCurrentDirectory();
700701
const resolvedLibraries: Map<ResolvedLibrary> = {};
701702
const libraryRoot = options.rootDir || options.configFilePath || computeCommonSourceDirectoryOfFilenames(rootNames);
702703
const programDiagnostics = createDiagnosticCollection();
@@ -715,7 +716,6 @@ namespace ts {
715716
// Map storing if there is emit blocking diagnostics for given input
716717
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);
717718

718-
const currentDirectory = host.getCurrentDirectory();
719719
const resolveModuleNamesWorker = host.resolveModuleNames
720720
? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile))
721721
: ((moduleNames: string[], containingFile: string) => {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [tests/cases/conformance/references/library-reference-1.ts] ////
2+
3+
//// [index.d.ts]
4+
5+
// We can find typings in the ./typings folder
6+
7+
declare var $: { foo(): void };
8+
9+
10+
//// [consumer.ts]
11+
/// <reference library="jquery" />
12+
$.foo();
13+
14+
15+
//// [consumer.js]
16+
/// <reference library="jquery" />
17+
$.foo();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/references/consumer.ts ===
2+
/// <reference library="jquery" />
3+
$.foo();
4+
>$.foo : Symbol(foo, Decl(index.d.ts, 3, 16))
5+
>$ : Symbol($, Decl(index.d.ts, 3, 11))
6+
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
7+
8+
=== tests/cases/conformance/references/typings/jquery/index.d.ts ===
9+
10+
// We can find typings in the ./typings folder
11+
12+
declare var $: { foo(): void };
13+
>$ : Symbol($, Decl(index.d.ts, 3, 11))
14+
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
15+
16+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/conformance/references/consumer.ts ===
2+
/// <reference library="jquery" />
3+
$.foo();
4+
>$.foo() : void
5+
>$.foo : () => void
6+
>$ : { foo(): void; }
7+
>foo : () => void
8+
9+
=== tests/cases/conformance/references/typings/jquery/index.d.ts ===
10+
11+
// We can find typings in the ./typings folder
12+
13+
declare var $: { foo(): void };
14+
>$ : { foo(): void; }
15+
>foo : () => void
16+
17+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [tests/cases/conformance/references/library-reference-2.ts] ////
2+
3+
//// [package.json]
4+
5+
// package.json in a primary reference can refer to another file
6+
7+
{
8+
"typings": "jquery.d.ts"
9+
}
10+
11+
//// [jquery.d.ts]
12+
declare var $: { foo(): void };
13+
14+
15+
//// [consumer.ts]
16+
/// <reference library="jquery" />
17+
$.foo();
18+
19+
20+
//// [consumer.js]
21+
/// <reference library="jquery" />
22+
$.foo();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/references/consumer.ts ===
2+
/// <reference library="jquery" />
3+
$.foo();
4+
>$.foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
5+
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
6+
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
7+
8+
=== tests/cases/conformance/references/typings/jquery/jquery.d.ts ===
9+
declare var $: { foo(): void };
10+
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
11+
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
12+
13+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/conformance/references/consumer.ts ===
2+
/// <reference library="jquery" />
3+
$.foo();
4+
>$.foo() : void
5+
>$.foo : () => void
6+
>$ : { foo(): void; }
7+
>foo : () => void
8+
9+
=== tests/cases/conformance/references/typings/jquery/jquery.d.ts ===
10+
declare var $: { foo(): void };
11+
>$ : { foo(): void; }
12+
>foo : () => void
13+
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [tests/cases/conformance/references/library-reference-3.ts] ////
2+
3+
//// [index.d.ts]
4+
5+
// Secondary references are possible
6+
7+
declare var $: { foo(): void };
8+
9+
//// [consumer.ts]
10+
/// <reference library="jquery" />
11+
$.foo();
12+
13+
14+
//// [consumer.js]
15+
/// <reference library="jquery" />
16+
$.foo();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/conformance/references/src/consumer.ts ===
2+
/// <reference library="jquery" />
3+
$.foo();
4+
>$.foo : Symbol(foo, Decl(index.d.ts, 3, 16))
5+
>$ : Symbol($, Decl(index.d.ts, 3, 11))
6+
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
7+
8+
=== tests/cases/conformance/references/src/node_modules/jquery/index.d.ts ===
9+
10+
// Secondary references are possible
11+
12+
declare var $: { foo(): void };
13+
>$ : Symbol($, Decl(index.d.ts, 3, 11))
14+
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/references/src/consumer.ts ===
2+
/// <reference library="jquery" />
3+
$.foo();
4+
>$.foo() : void
5+
>$.foo : () => void
6+
>$ : { foo(): void; }
7+
>foo : () => void
8+
9+
=== tests/cases/conformance/references/src/node_modules/jquery/index.d.ts ===
10+
11+
// Secondary references are possible
12+
13+
declare var $: { foo(): void };
14+
>$ : { foo(): void; }
15+
>foo : () => void
16+

0 commit comments

Comments
 (0)