Skip to content

Commit 0b71df5

Browse files
author
Andy Hanson
committed
Add a .d.ts file to the test to ensure it is excluded from the calculation too
1 parent 2eca0af commit 0b71df5

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

tests/baselines/reference/commonSourceDirectory.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55

66
export const x = 0;
77

8+
//// [bar.d.ts]
9+
declare module "bar" {
10+
export const y = 0;
11+
}
12+
813
//// [index.ts]
14+
/// <reference path="../types/bar.d.ts"/>
915
import { x } from "foo";
10-
x + 1;
16+
import { y } from "bar";
17+
x + y;
1118

1219

1320
//// [/app/bin/index.js]
1421
"use strict";
22+
/// <reference path="../types/bar.d.ts"/>
1523
var foo_1 = require("foo");
16-
foo_1.x + 1;
24+
var bar_1 = require("bar");
25+
foo_1.x + bar_1.y;
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
=== /app/index.ts ===
2+
/// <reference path="../types/bar.d.ts"/>
23
import { x } from "foo";
3-
>x : Symbol(x, Decl(index.ts, 0, 8))
4+
>x : Symbol(x, Decl(index.ts, 1, 8))
45

5-
x + 1;
6-
>x : Symbol(x, Decl(index.ts, 0, 8))
6+
import { y } from "bar";
7+
>y : Symbol(y, Decl(index.ts, 2, 8))
8+
9+
x + y;
10+
>x : Symbol(x, Decl(index.ts, 1, 8))
11+
>y : Symbol(y, Decl(index.ts, 2, 8))
712

813
=== /node_modules/foo/index.ts ===
914
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
1015

1116
export const x = 0;
1217
>x : Symbol(x, Decl(index.ts, 2, 12))
1318

19+
=== /types/bar.d.ts ===
20+
declare module "bar" {
21+
export const y = 0;
22+
>y : Symbol(y, Decl(bar.d.ts, 1, 16))
23+
}
24+
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
=== /app/index.ts ===
2+
/// <reference path="../types/bar.d.ts"/>
23
import { x } from "foo";
34
>x : 0
45

5-
x + 1;
6-
>x + 1 : number
6+
import { y } from "bar";
7+
>y : 0
8+
9+
x + y;
10+
>x + y : number
711
>x : 0
8-
>1 : 1
12+
>y : 0
913

1014
=== /node_modules/foo/index.ts ===
1115
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
@@ -14,3 +18,10 @@ export const x = 0;
1418
>x : 0
1519
>0 : 0
1620

21+
=== /types/bar.d.ts ===
22+
declare module "bar" {
23+
export const y = 0;
24+
>y : 0
25+
>0 : 0
26+
}
27+

tests/cases/compiler/commonSourceDirectory.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
// @filename: /node_modules/foo/index.ts
77
export const x = 0;
88

9+
// @filename: /types/bar.d.ts
10+
declare module "bar" {
11+
export const y = 0;
12+
}
13+
914
// @filename: /app/index.ts
15+
/// <reference path="../types/bar.d.ts"/>
1016
import { x } from "foo";
11-
x + 1;
17+
import { y } from "bar";
18+
x + y;
1219

1320
// @filename: /app/tsconfig.json
1421
{
1522
"compilerOptions": {
16-
"outDir": "bin"
23+
"outDir": "bin",
24+
"typeRoots": ["../types"]
1725
}
1826
}

0 commit comments

Comments
 (0)