@@ -449,5 +449,81 @@ declare namespace myapp {
449
449
} ,
450
450
changes : emptyArray
451
451
} ) ;
452
+
453
+ describe ( "works when installing something in node_modules or @types when there is no notification from fs for index file" , ( ) => {
454
+ function getNodeAtTypes ( ) {
455
+ const nodeAtTypesIndex : File = {
456
+ path : `${ projectRoot } /node_modules/@types/node/index.d.ts` ,
457
+ content : `/// <reference path="base.d.ts" />`
458
+ } ;
459
+ const nodeAtTypesBase : File = {
460
+ path : `${ projectRoot } /node_modules/@types/node/base.d.ts` ,
461
+ content : `// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
462
+ /// <reference path="ts3.6/base.d.ts" />`
463
+ } ;
464
+ const nodeAtTypes36Base : File = {
465
+ path : `${ projectRoot } /node_modules/@types/node/ts3.6/base.d.ts` ,
466
+ content : `/// <reference path="../globals.d.ts" />`
467
+ } ;
468
+ const nodeAtTypesGlobals : File = {
469
+ path : `${ projectRoot } /node_modules/@types/node/globals.d.ts` ,
470
+ content : `declare var process: NodeJS.Process;
471
+ declare namespace NodeJS {
472
+ interface Process {
473
+ on(msg: string): void;
474
+ }
475
+ }`
476
+ } ;
477
+ return { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } ;
478
+ }
479
+ verifyTscWatch ( {
480
+ scenario,
481
+ subScenario : "works when installing something in node_modules or @types when there is no notification from fs for index file" ,
482
+ commandLineArgs : [ "--w" , `--extendedDiagnostics` ] ,
483
+ sys : ( ) => {
484
+ const file : File = {
485
+ path : `${ projectRoot } /worker.ts` ,
486
+ content : `process.on("uncaughtException");`
487
+ } ;
488
+ const tsconfig : File = {
489
+ path : `${ projectRoot } /tsconfig.json` ,
490
+ content : "{}"
491
+ } ;
492
+ const { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } = getNodeAtTypes ( ) ;
493
+ return createWatchedSystem ( [ file , libFile , tsconfig , nodeAtTypesIndex , nodeAtTypesBase , nodeAtTypes36Base , nodeAtTypesGlobals ] , { currentDirectory : projectRoot } ) ;
494
+ } ,
495
+ changes : [
496
+ {
497
+ caption : "npm ci step one: remove all node_modules files" ,
498
+ change : sys => sys . deleteFolder ( `${ projectRoot } /node_modules/@types` , /*recursive*/ true ) ,
499
+ timeouts : runQueuedTimeoutCallbacks ,
500
+ } ,
501
+ {
502
+ caption : `npm ci step two: create atTypes but something else in the @types folder` ,
503
+ change : sys => sys . ensureFileOrFolder ( {
504
+ path : `${ projectRoot } /node_modules/@types/mocha/index.d.ts` ,
505
+ content : `export const foo = 10;`
506
+ } ) ,
507
+ timeouts : runQueuedTimeoutCallbacks
508
+ } ,
509
+ {
510
+ caption : `npm ci step three: create atTypes node folder` ,
511
+ change : sys => sys . ensureFileOrFolder ( { path : `${ projectRoot } /node_modules/@types/node` } ) ,
512
+ timeouts : runQueuedTimeoutCallbacks
513
+ } ,
514
+ {
515
+ caption : `npm ci step four: create atTypes write all the files but dont invoke watcher for index.d.ts` ,
516
+ change : sys => {
517
+ const { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } = getNodeAtTypes ( ) ;
518
+ sys . ensureFileOrFolder ( nodeAtTypesBase ) ;
519
+ sys . ensureFileOrFolder ( nodeAtTypesIndex , /*ignoreWatchInvokedWithTriggerAsFileCreate*/ true ) ;
520
+ sys . ensureFileOrFolder ( nodeAtTypes36Base , /*ignoreWatchInvokedWithTriggerAsFileCreate*/ true ) ;
521
+ sys . ensureFileOrFolder ( nodeAtTypesGlobals , /*ignoreWatchInvokedWithTriggerAsFileCreate*/ true ) ;
522
+ } ,
523
+ timeouts : runQueuedTimeoutCallbacks
524
+ } ,
525
+ ]
526
+ } ) ;
527
+ } ) ;
452
528
} ) ;
453
529
}
0 commit comments