From 0b71df50997de7e09ff91836b7190ba237ab235d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 3 Nov 2016 12:28:19 -0700 Subject: [PATCH] Add a `.d.ts` file to the test to ensure it is excluded from the calculation too --- .../reference/commonSourceDirectory.js | 13 +++++++++++-- .../reference/commonSourceDirectory.symbols | 17 ++++++++++++++--- .../reference/commonSourceDirectory.types | 17 ++++++++++++++--- tests/cases/compiler/commonSourceDirectory.ts | 12 ++++++++++-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/commonSourceDirectory.js b/tests/baselines/reference/commonSourceDirectory.js index 3babba98337..5299095ae74 100644 --- a/tests/baselines/reference/commonSourceDirectory.js +++ b/tests/baselines/reference/commonSourceDirectory.js @@ -5,12 +5,21 @@ export const x = 0; +//// [bar.d.ts] +declare module "bar" { + export const y = 0; +} + //// [index.ts] +/// import { x } from "foo"; -x + 1; +import { y } from "bar"; +x + y; //// [/app/bin/index.js] "use strict"; +/// var foo_1 = require("foo"); -foo_1.x + 1; +var bar_1 = require("bar"); +foo_1.x + bar_1.y; diff --git a/tests/baselines/reference/commonSourceDirectory.symbols b/tests/baselines/reference/commonSourceDirectory.symbols index 88ded4c8c87..5409286ede5 100644 --- a/tests/baselines/reference/commonSourceDirectory.symbols +++ b/tests/baselines/reference/commonSourceDirectory.symbols @@ -1,9 +1,14 @@ === /app/index.ts === +/// import { x } from "foo"; ->x : Symbol(x, Decl(index.ts, 0, 8)) +>x : Symbol(x, Decl(index.ts, 1, 8)) -x + 1; ->x : Symbol(x, Decl(index.ts, 0, 8)) +import { y } from "bar"; +>y : Symbol(y, Decl(index.ts, 2, 8)) + +x + y; +>x : Symbol(x, Decl(index.ts, 1, 8)) +>y : Symbol(y, Decl(index.ts, 2, 8)) === /node_modules/foo/index.ts === // Test that importing a file from `node_modules` does not affect calculation of the common source directory. @@ -11,3 +16,9 @@ x + 1; export const x = 0; >x : Symbol(x, Decl(index.ts, 2, 12)) +=== /types/bar.d.ts === +declare module "bar" { + export const y = 0; +>y : Symbol(y, Decl(bar.d.ts, 1, 16)) +} + diff --git a/tests/baselines/reference/commonSourceDirectory.types b/tests/baselines/reference/commonSourceDirectory.types index a0c66b86ae0..ce0169582d7 100644 --- a/tests/baselines/reference/commonSourceDirectory.types +++ b/tests/baselines/reference/commonSourceDirectory.types @@ -1,11 +1,15 @@ === /app/index.ts === +/// import { x } from "foo"; >x : 0 -x + 1; ->x + 1 : number +import { y } from "bar"; +>y : 0 + +x + y; +>x + y : number >x : 0 ->1 : 1 +>y : 0 === /node_modules/foo/index.ts === // 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; >x : 0 >0 : 0 +=== /types/bar.d.ts === +declare module "bar" { + export const y = 0; +>y : 0 +>0 : 0 +} + diff --git a/tests/cases/compiler/commonSourceDirectory.ts b/tests/cases/compiler/commonSourceDirectory.ts index 6583da67c6a..930f922e10d 100644 --- a/tests/cases/compiler/commonSourceDirectory.ts +++ b/tests/cases/compiler/commonSourceDirectory.ts @@ -6,13 +6,21 @@ // @filename: /node_modules/foo/index.ts export const x = 0; +// @filename: /types/bar.d.ts +declare module "bar" { + export const y = 0; +} + // @filename: /app/index.ts +/// import { x } from "foo"; -x + 1; +import { y } from "bar"; +x + y; // @filename: /app/tsconfig.json { "compilerOptions": { - "outDir": "bin" + "outDir": "bin", + "typeRoots": ["../types"] } }