Skip to content

Commit 0422a75

Browse files
author
Andy Hanson
committed
Add test with a referenced dts file
1 parent 07630e9 commit 0422a75

File tree

6 files changed

+111
-0
lines changed

6 files changed

+111
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/compiler/commonSourceDirectory_dts.ts] ////
2+
3+
//// [bar.d.ts]
4+
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
5+
6+
declare const y: number;
7+
8+
//// [index.ts]
9+
/// <reference path="../lib/bar.d.ts" />
10+
export const x = y;
11+
12+
13+
//// [/app/bin/index.js]
14+
"use strict";
15+
/// <reference path="../lib/bar.d.ts" />
16+
exports.x = y;
17+
//# sourceMappingURL=/app/myMapRoot/index.js.map
18+
19+
//// [/app/bin/index.d.ts]
20+
/// <reference path="../lib/bar.d.ts" />
21+
export declare const x: number;

tests/baselines/reference/commonSourceDirectory_dts.js.map

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
===================================================================
2+
JsFile: index.js
3+
mapUrl: /app/myMapRoot/index.js.map
4+
sourceRoot: /app/mySourceRoot/
5+
sources: index.ts
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:/app/bin/index.js
9+
sourceFile:index.ts
10+
-------------------------------------------------------------------
11+
>>>"use strict";
12+
>>>/// <reference path="../lib/bar.d.ts" />
13+
1 >
14+
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
1 >
16+
2 >/// <reference path="../lib/bar.d.ts" />
17+
1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0)
18+
2 >Emitted(2, 41) Source(1, 41) + SourceIndex(0)
19+
---
20+
>>>exports.x = y;
21+
1 >
22+
2 >^^^^^^^^
23+
3 > ^
24+
4 > ^^^
25+
5 > ^
26+
6 > ^
27+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
28+
1 >
29+
>export const
30+
2 >
31+
3 > x
32+
4 > =
33+
5 > y
34+
6 > ;
35+
1 >Emitted(3, 1) Source(2, 14) + SourceIndex(0)
36+
2 >Emitted(3, 9) Source(2, 14) + SourceIndex(0)
37+
3 >Emitted(3, 10) Source(2, 15) + SourceIndex(0)
38+
4 >Emitted(3, 13) Source(2, 18) + SourceIndex(0)
39+
5 >Emitted(3, 14) Source(2, 19) + SourceIndex(0)
40+
6 >Emitted(3, 15) Source(2, 20) + SourceIndex(0)
41+
---
42+
>>>//# sourceMappingURL=/app/myMapRoot/index.js.map
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== /app/src/index.ts ===
2+
/// <reference path="../lib/bar.d.ts" />
3+
export const x = y;
4+
>x : Symbol(x, Decl(index.ts, 1, 12))
5+
>y : Symbol(y, Decl(bar.d.ts, 2, 13))
6+
7+
=== /app/lib/bar.d.ts ===
8+
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
9+
10+
declare const y: number;
11+
>y : Symbol(y, Decl(bar.d.ts, 2, 13))
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== /app/src/index.ts ===
2+
/// <reference path="../lib/bar.d.ts" />
3+
export const x = y;
4+
>x : number
5+
>y : number
6+
7+
=== /app/lib/bar.d.ts ===
8+
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
9+
10+
declare const y: number;
11+
>y : number
12+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
2+
// @noImplicitReferences: true
3+
// @moduleResolution: node
4+
// @fullEmitPaths: true
5+
6+
// @filename: /app/lib/bar.d.ts
7+
declare const y: number;
8+
9+
// @filename: /app/src/index.ts
10+
/// <reference path="../lib/bar.d.ts" />
11+
export const x = y;
12+
13+
// @filename: /app/tsconfig.json
14+
{
15+
"compilerOptions": {
16+
"outDir": "bin",
17+
"sourceMap": true,
18+
"mapRoot": "myMapRoot",
19+
"sourceRoot": "mySourceRoot",
20+
"declaration": true
21+
}
22+
}

0 commit comments

Comments
 (0)