Add test with a referenced dts file

This commit is contained in:
Andy Hanson
2016-11-10 10:15:42 -08:00
parent 07630e95e0
commit 0422a756d9
6 changed files with 111 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
//// [tests/cases/compiler/commonSourceDirectory_dts.ts] ////
//// [bar.d.ts]
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
declare const y: number;
//// [index.ts]
/// <reference path="../lib/bar.d.ts" />
export const x = y;
//// [/app/bin/index.js]
"use strict";
/// <reference path="../lib/bar.d.ts" />
exports.x = y;
//# sourceMappingURL=/app/myMapRoot/index.js.map
//// [/app/bin/index.d.ts]
/// <reference path="../lib/bar.d.ts" />
export declare const x: number;

View File

@@ -0,0 +1,2 @@
//// [/app/bin/index.js.map]
{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"}

View File

@@ -0,0 +1,42 @@
===================================================================
JsFile: index.js
mapUrl: /app/myMapRoot/index.js.map
sourceRoot: /app/mySourceRoot/
sources: index.ts
===================================================================
-------------------------------------------------------------------
emittedFile:/app/bin/index.js
sourceFile:index.ts
-------------------------------------------------------------------
>>>"use strict";
>>>/// <reference path="../lib/bar.d.ts" />
1 >
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 >
2 >/// <reference path="../lib/bar.d.ts" />
1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(2, 41) Source(1, 41) + SourceIndex(0)
---
>>>exports.x = y;
1 >
2 >^^^^^^^^
3 > ^
4 > ^^^
5 > ^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>export const
2 >
3 > x
4 > =
5 > y
6 > ;
1 >Emitted(3, 1) Source(2, 14) + SourceIndex(0)
2 >Emitted(3, 9) Source(2, 14) + SourceIndex(0)
3 >Emitted(3, 10) Source(2, 15) + SourceIndex(0)
4 >Emitted(3, 13) Source(2, 18) + SourceIndex(0)
5 >Emitted(3, 14) Source(2, 19) + SourceIndex(0)
6 >Emitted(3, 15) Source(2, 20) + SourceIndex(0)
---
>>>//# sourceMappingURL=/app/myMapRoot/index.js.map

View File

@@ -0,0 +1,12 @@
=== /app/src/index.ts ===
/// <reference path="../lib/bar.d.ts" />
export const x = y;
>x : Symbol(x, Decl(index.ts, 1, 12))
>y : Symbol(y, Decl(bar.d.ts, 2, 13))
=== /app/lib/bar.d.ts ===
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
declare const y: number;
>y : Symbol(y, Decl(bar.d.ts, 2, 13))

View File

@@ -0,0 +1,12 @@
=== /app/src/index.ts ===
/// <reference path="../lib/bar.d.ts" />
export const x = y;
>x : number
>y : number
=== /app/lib/bar.d.ts ===
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
declare const y: number;
>y : number

View File

@@ -0,0 +1,22 @@
// Test that importing a file from `node_modules` does not affect calculation of the common source directory.
// @noImplicitReferences: true
// @moduleResolution: node
// @fullEmitPaths: true
// @filename: /app/lib/bar.d.ts
declare const y: number;
// @filename: /app/src/index.ts
/// <reference path="../lib/bar.d.ts" />
export const x = y;
// @filename: /app/tsconfig.json
{
"compilerOptions": {
"outDir": "bin",
"sourceMap": true,
"mapRoot": "myMapRoot",
"sourceRoot": "mySourceRoot",
"declaration": true
}
}