1
1
namespace ts . tscWatch {
2
2
describe ( "unittests:: tsc-watch:: Emit times and Error updates in builder after program changes" , ( ) => {
3
- const currentDirectory = "/user/username/projects/myproject" ;
4
3
const config : File = {
5
- path : `${ currentDirectory } /tsconfig.json` ,
4
+ path : `${ projectRoot } /tsconfig.json` ,
6
5
content : `{}`
7
6
} ;
8
7
function getOutputFileStampAndError ( host : WatchedSystem , watch : Watch , file : File ) {
@@ -83,7 +82,7 @@ namespace ts.tscWatch {
83
82
const nonLibFiles = [ ...filesWithNewEmit , ...filesWithOnlyErrorRefresh , ...filesNotTouched ] ;
84
83
const files = [ ...nonLibFiles , configFile , libFile ] ;
85
84
const compilerOptions = ( JSON . parse ( configFile . content ) . compilerOptions || { } ) as CompilerOptions ;
86
- const host = createWatchedSystem ( files , { currentDirectory } ) ;
85
+ const host = createWatchedSystem ( files , { currentDirectory : projectRoot } ) ;
87
86
const watch = createWatchOfConfigFile ( "tsconfig.json" , host ) ;
88
87
checkProgramActualFiles ( watch ( ) , [ ...nonLibFiles . map ( f => f . path ) , libFile . path ] ) ;
89
88
checkOutputErrorsInitial ( host , getInitialErrors ( watch ) ) ;
@@ -167,7 +166,7 @@ namespace ts.tscWatch {
167
166
168
167
describe ( "deep import changes" , ( ) => {
169
168
const aFile : File = {
170
- path : `${ currentDirectory } /a.ts` ,
169
+ path : `${ projectRoot } /a.ts` ,
171
170
content : `import {B} from './b';
172
171
declare var console: any;
173
172
let b = new B();
@@ -203,15 +202,15 @@ console.log(b.c.d);`
203
202
204
203
describe ( "updates errors when deep import file changes" , ( ) => {
205
204
const bFile : File = {
206
- path : `${ currentDirectory } /b.ts` ,
205
+ path : `${ projectRoot } /b.ts` ,
207
206
content : `import {C} from './c';
208
207
export class B
209
208
{
210
209
c = new C();
211
210
}`
212
211
} ;
213
212
const cFile : File = {
214
- path : `${ currentDirectory } /c.ts` ,
213
+ path : `${ projectRoot } /c.ts` ,
215
214
content : `export class C
216
215
{
217
216
d = 1;
@@ -222,15 +221,15 @@ export class B
222
221
223
222
describe ( "updates errors when deep import through declaration file changes" , ( ) => {
224
223
const bFile : File = {
225
- path : `${ currentDirectory } /b.d.ts` ,
224
+ path : `${ projectRoot } /b.d.ts` ,
226
225
content : `import {C} from './c';
227
226
export class B
228
227
{
229
228
c: C;
230
229
}`
231
230
} ;
232
231
const cFile : File = {
233
- path : `${ currentDirectory } /c.d.ts` ,
232
+ path : `${ projectRoot } /c.d.ts` ,
234
233
content : `export class C
235
234
{
236
235
d: number;
@@ -242,7 +241,7 @@ export class B
242
241
243
242
describe ( "updates errors in file not exporting a deep multilevel import that changes" , ( ) => {
244
243
const aFile : File = {
245
- path : `${ currentDirectory } /a.ts` ,
244
+ path : `${ projectRoot } /a.ts` ,
246
245
content : `export interface Point {
247
246
name: string;
248
247
c: Coords;
@@ -253,13 +252,13 @@ export interface Coords {
253
252
}`
254
253
} ;
255
254
const bFile : File = {
256
- path : `${ currentDirectory } /b.ts` ,
255
+ path : `${ projectRoot } /b.ts` ,
257
256
content : `import { Point } from "./a";
258
257
export interface PointWrapper extends Point {
259
258
}`
260
259
} ;
261
260
const cFile : File = {
262
- path : `${ currentDirectory } /c.ts` ,
261
+ path : `${ projectRoot } /c.ts` ,
263
262
content : `import { PointWrapper } from "./b";
264
263
export function getPoint(): PointWrapper {
265
264
return {
@@ -272,12 +271,12 @@ export function getPoint(): PointWrapper {
272
271
};`
273
272
} ;
274
273
const dFile : File = {
275
- path : `${ currentDirectory } /d.ts` ,
274
+ path : `${ projectRoot } /d.ts` ,
276
275
content : `import { getPoint } from "./c";
277
276
getPoint().c.x;`
278
277
} ;
279
278
const eFile : File = {
280
- path : `${ currentDirectory } /e.ts` ,
279
+ path : `${ projectRoot } /e.ts` ,
281
280
content : `import "./d";`
282
281
} ;
283
282
verifyEmitAndErrorUpdates ( {
@@ -301,14 +300,14 @@ getPoint().c.x;`
301
300
302
301
describe ( "updates errors when file transitively exported file changes" , ( ) => {
303
302
const config : File = {
304
- path : `${ currentDirectory } /tsconfig.json` ,
303
+ path : `${ projectRoot } /tsconfig.json` ,
305
304
content : JSON . stringify ( {
306
305
files : [ "app.ts" ] ,
307
306
compilerOptions : { baseUrl : "." }
308
307
} )
309
308
} ;
310
309
const app : File = {
311
- path : `${ currentDirectory } /app.ts` ,
310
+ path : `${ projectRoot } /app.ts` ,
312
311
content : `import { Data } from "lib2/public";
313
312
export class App {
314
313
public constructor() {
@@ -317,11 +316,11 @@ export class App {
317
316
}`
318
317
} ;
319
318
const lib2Public : File = {
320
- path : `${ currentDirectory } /lib2/public.ts` ,
319
+ path : `${ projectRoot } /lib2/public.ts` ,
321
320
content : `export * from "./data";`
322
321
} ;
323
322
const lib2Data : File = {
324
- path : `${ currentDirectory } /lib2/data.ts` ,
323
+ path : `${ projectRoot } /lib2/data.ts` ,
325
324
content : `import { ITest } from "lib1/public";
326
325
export class Data {
327
326
public test() {
@@ -333,15 +332,15 @@ export class Data {
333
332
}`
334
333
} ;
335
334
const lib1Public : File = {
336
- path : `${ currentDirectory } /lib1/public.ts` ,
335
+ path : `${ projectRoot } /lib1/public.ts` ,
337
336
content : `export * from "./tools/public";`
338
337
} ;
339
338
const lib1ToolsPublic : File = {
340
- path : `${ currentDirectory } /lib1/tools/public.ts` ,
339
+ path : `${ projectRoot } /lib1/tools/public.ts` ,
341
340
content : `export * from "./tools.interface";`
342
341
} ;
343
342
const lib1ToolsInterface : File = {
344
- path : `${ currentDirectory } /lib1/tools/tools.interface.ts` ,
343
+ path : `${ projectRoot } /lib1/tools/tools.interface.ts` ,
345
344
content : `export interface ITest {
346
345
title: string;
347
346
}`
@@ -372,7 +371,7 @@ export class Data {
372
371
373
372
describe ( "when there are circular import and exports" , ( ) => {
374
373
const lib2Data : File = {
375
- path : `${ currentDirectory } /lib2/data.ts` ,
374
+ path : `${ projectRoot } /lib2/data.ts` ,
376
375
content : `import { ITest } from "lib1/public"; import { Data2 } from "./data2";
377
376
export class Data {
378
377
public dat?: Data2; public test() {
@@ -384,7 +383,7 @@ export class Data {
384
383
}`
385
384
} ;
386
385
const lib2Data2 : File = {
387
- path : `${ currentDirectory } /lib2/data2.ts` ,
386
+ path : `${ projectRoot } /lib2/data2.ts` ,
388
387
content : `import { Data } from "./data";
389
388
export class Data2 {
390
389
public dat?: Data;
0 commit comments