55 jsonToReadableText ,
66} from "../helpers" ;
77import {
8- getSampleProjectConfigWithNodeNext ,
8+ getProjectConfigWithNodeNext ,
9+ } from "../helpers/contents" ;
10+ import {
911 getSysForSampleProjectReferences ,
1012} from "../helpers/sampleProjectReferences" ;
1113import {
@@ -28,7 +30,7 @@ import {
2830} from "../helpers/virtualFileSystemWithWatch" ;
2931
3032describe ( "unittests:: tsc-watch:: projects with references: invoking when references are already built" , ( ) => {
31- function verify ( withNodeNext : boolean ) {
33+ function verifySampleProject ( withNodeNext : boolean ) {
3234 verifyTscWatch ( {
3335 scenario : "projectsWithReferences" ,
3436 subScenario : `on sample project${ withNodeNext ? " with nodenext" : "" } ` ,
@@ -66,7 +68,7 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
6668 "/user/username/projects/sample1/logic/tsconfig.json" ,
6769 jsonToReadableText ( {
6870 compilerOptions : {
69- ...getSampleProjectConfigWithNodeNext ( withNodeNext ) ,
71+ ...getProjectConfigWithNodeNext ( withNodeNext ) ,
7072 composite : true ,
7173 declaration : true ,
7274 declarationDir : "decls" ,
@@ -83,86 +85,90 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
8385 baselineDependencies : true ,
8486 } ) ;
8587 }
86- verify ( /*withNodeNext*/ false ) ;
87- verify ( /*withNodeNext*/ true ) ;
88+ verifySampleProject ( /*withNodeNext*/ false ) ;
89+ verifySampleProject ( /*withNodeNext*/ true ) ;
8890
8991 function changeCompilerOpitonsPaths ( sys : TestServerHost , config : string , newPaths : object ) {
9092 const configJson = JSON . parse ( sys . readFile ( config ) ! ) ;
9193 configJson . compilerOptions . paths = newPaths ;
9294 sys . writeFile ( config , jsonToReadableText ( configJson ) ) ;
9395 }
9496
95- verifyTscWatch ( {
96- scenario : "projectsWithReferences" ,
97- subScenario : "on transitive references" ,
98- sys : ( ) =>
99- solutionBuildWithBaseline (
100- createWatchedSystem (
101- getFsContentsForTransitiveReferences ( ) ,
102- { currentDirectory : `/user/username/projects/transitiveReferences` } ,
97+ function verifyTransitiveReferences ( withNodeNext : boolean ) {
98+ verifyTscWatch ( {
99+ scenario : "projectsWithReferences" ,
100+ subScenario : `on transitive references${ withNodeNext ? " with nodenext" : "" } ` ,
101+ sys : ( ) =>
102+ solutionBuildWithBaseline (
103+ createWatchedSystem (
104+ getFsContentsForTransitiveReferences ( withNodeNext ) ,
105+ { currentDirectory : `/user/username/projects/transitiveReferences` } ,
106+ ) ,
107+ [ "tsconfig.c.json" ] ,
103108 ) ,
104- [ "tsconfig.c.json" ] ,
105- ) ,
106- commandLineArgs : [ "-w" , "-p" , "tsconfig.c.json" , "--traceResolution" , "--explainFiles" ] ,
107- edits : [
108- {
109- caption : "non local edit b ts, and build b" ,
110- edit : sys => {
111- sys . appendFile ( "b.ts" , `export function gfoo() { }` ) ;
112- const solutionBuilder = createSolutionBuilder ( sys , [ "tsconfig.b.json" ] ) ;
113- solutionBuilder . build ( ) ;
109+ commandLineArgs : [ "-w" , "-p" , "tsconfig.c.json" , "--traceResolution" , "--explainFiles "] ,
110+ edits : [
111+ {
112+ caption : "non local edit b ts, and build b" ,
113+ edit : sys => {
114+ sys . appendFile ( "b.ts" , `export function gfoo() { }` ) ;
115+ const solutionBuilder = createSolutionBuilder ( sys , [ "tsconfig.b.json" ] ) ;
116+ solutionBuilder . build ( ) ;
117+ } ,
118+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
114119 } ,
115- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
116- } ,
117- {
118- caption : "edit on config file" ,
119- edit : sys => {
120- sys . ensureFileOrFolder ( {
121- path : "/user/username/projects/transitiveReferences/nrefs/a.d.ts" ,
122- content : sys . readFile ( "/user/username/projects/transitiveReferences/refs/a.d.ts" ) ! ,
123- } ) ;
124- changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ;
120+ {
121+ caption : "edit on config file" ,
122+ edit : sys => {
123+ sys . ensureFileOrFolder ( {
124+ path : "/user/username/projects/transitiveReferences/nrefs/a.d.ts" ,
125+ content : sys . readFile ( "/user/username/projects/transitiveReferences/refs/a.d.ts" ) ! ,
126+ } ) ;
127+ changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ;
128+ } ,
129+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
125130 } ,
126- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
127- } ,
128- {
129- caption : "Revert config file edit" ,
130- edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
131- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
132- } ,
133- {
134- caption : "edit in referenced config file" ,
135- edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ,
136- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
137- } ,
138- {
139- caption : "Revert referenced config file edit" ,
140- edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
141- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
142- } ,
143- {
144- caption : "deleting referenced config file" ,
145- edit : sys => sys . deleteFile ( "tsconfig.b.json" ) ,
146- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
147- } ,
148- {
149- caption : "Revert deleting referenced config file" ,
150- edit : sys => sys . writeFile ( "tsconfig.b.json" , getFsContentsForTransitiveReferencesBConfig ( ) ) ,
151- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
152- } ,
153- {
154- caption : "deleting transitively referenced config file" ,
155- edit : sys => sys . deleteFile ( "tsconfig.a.json" ) ,
156- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
157- } ,
158- {
159- caption : "Revert deleting transitively referenced config file" ,
160- edit : sys => sys . writeFile ( "tsconfig.a.json" , getFsContentsForTransitiveReferencesAConfig ( ) ) ,
161- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
162- } ,
163- ] ,
164- baselineDependencies : true ,
165- } ) ;
131+ {
132+ caption : "Revert config file edit" ,
133+ edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
134+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
135+ } ,
136+ {
137+ caption : "edit in referenced config file" ,
138+ edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ,
139+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
140+ } ,
141+ {
142+ caption : "Revert referenced config file edit" ,
143+ edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
144+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
145+ } ,
146+ {
147+ caption : "deleting referenced config file" ,
148+ edit : sys => sys . deleteFile ( "tsconfig.b.json" ) ,
149+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
150+ } ,
151+ {
152+ caption : "Revert deleting referenced config file" ,
153+ edit : sys => sys . writeFile ( "tsconfig.b.json" , getFsContentsForTransitiveReferencesBConfig ( withNodeNext ) ) ,
154+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
155+ } ,
156+ {
157+ caption : "deleting transitively referenced config file" ,
158+ edit : sys => sys . deleteFile ( "tsconfig.a.json" ) ,
159+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
160+ } ,
161+ {
162+ caption : "Revert deleting transitively referenced config file" ,
163+ edit : sys => sys . writeFile ( "tsconfig.a.json" , getFsContentsForTransitiveReferencesAConfig ( withNodeNext ) ) ,
164+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
165+ } ,
166+ ] ,
167+ baselineDependencies : true ,
168+ } ) ;
169+ }
170+ verifyTransitiveReferences ( /*withNodeNext*/ false ) ;
171+ verifyTransitiveReferences ( /*withNodeNext*/ true ) ;
166172
167173 verifyTscWatch ( {
168174 scenario : "projectsWithReferences" ,
0 commit comments