@@ -116,5 +116,124 @@ const a: string = "hello";`, "utf-8"),
116116const a: string = 10;` , "utf-8" ) ,
117117 ) ;
118118 } ) ;
119+
120+ describe ( "when noEmit changes between compilation" , ( ) => {
121+ verifyNoEmitChanges ( { incremental : true } ) ;
122+ verifyNoEmitChanges ( { incremental : true , declaration : true } ) ;
123+ verifyNoEmitChanges ( { composite : true } ) ;
124+
125+ function verifyNoEmitChanges ( compilerOptions : CompilerOptions ) {
126+ const noChangeRunWithNoEmit : TscIncremental = {
127+ subScenario : "No Change run with noEmit" ,
128+ commandLineArgs : [ "--p" , "src/project" , "--noEmit" ] ,
129+ ...noChangeRun ,
130+ } ;
131+ const noChangeRunWithEmit : TscIncremental = {
132+ subScenario : "No Change run with emit" ,
133+ commandLineArgs : [ "--p" , "src/project" ] ,
134+ ...noChangeRun ,
135+ } ;
136+ let optionsString = "" ;
137+ for ( const key in compilerOptions ) {
138+ if ( hasProperty ( compilerOptions , key ) ) {
139+ optionsString += ` ${ key } ` ;
140+ }
141+ }
142+
143+ verifyTscSerializedIncrementalEdits ( {
144+ scenario : "incremental" ,
145+ subScenario : `noEmit changes${ optionsString } ` ,
146+ commandLineArgs : [ "--p" , "src/project" ] ,
147+ fs,
148+ incrementalScenarios : [
149+ noChangeRunWithNoEmit ,
150+ noChangeRunWithNoEmit ,
151+ {
152+ subScenario : "Introduce error but still noEmit" ,
153+ commandLineArgs : [ "--p" , "src/project" , "--noEmit" ] ,
154+ modifyFs : fs => replaceText ( fs , "/src/project/src/class.ts" , "prop" , "prop1" ) ,
155+ buildKind : BuildKind . IncrementalDtsChange
156+ } ,
157+ {
158+ subScenario : "Fix error and emit" ,
159+ modifyFs : fs => replaceText ( fs , "/src/project/src/class.ts" , "prop1" , "prop" ) ,
160+ buildKind : BuildKind . IncrementalDtsChange
161+ } ,
162+ noChangeRunWithEmit ,
163+ noChangeRunWithNoEmit ,
164+ noChangeRunWithNoEmit ,
165+ noChangeRunWithEmit ,
166+ {
167+ subScenario : "Introduce error and emit" ,
168+ modifyFs : fs => replaceText ( fs , "/src/project/src/class.ts" , "prop" , "prop1" ) ,
169+ buildKind : BuildKind . IncrementalDtsChange
170+ } ,
171+ noChangeRunWithEmit ,
172+ noChangeRunWithNoEmit ,
173+ noChangeRunWithNoEmit ,
174+ noChangeRunWithEmit ,
175+ {
176+ subScenario : "Fix error and no emit" ,
177+ commandLineArgs : [ "--p" , "src/project" , "--noEmit" ] ,
178+ modifyFs : fs => replaceText ( fs , "/src/project/src/class.ts" , "prop1" , "prop" ) ,
179+ buildKind : BuildKind . IncrementalDtsChange
180+ } ,
181+ noChangeRunWithEmit ,
182+ noChangeRunWithNoEmit ,
183+ noChangeRunWithNoEmit ,
184+ noChangeRunWithEmit ,
185+ ] ,
186+ } ) ;
187+
188+ verifyTscSerializedIncrementalEdits ( {
189+ scenario : "incremental" ,
190+ subScenario : `noEmit changes with initial noEmit${ optionsString } ` ,
191+ commandLineArgs : [ "--p" , "src/project" , "--noEmit" ] ,
192+ fs,
193+ incrementalScenarios : [
194+ noChangeRunWithEmit ,
195+ {
196+ subScenario : "Introduce error with emit" ,
197+ commandLineArgs : [ "--p" , "src/project" ] ,
198+ modifyFs : fs => replaceText ( fs , "/src/project/src/class.ts" , "prop" , "prop1" ) ,
199+ buildKind : BuildKind . IncrementalDtsChange
200+ } ,
201+ {
202+ subScenario : "Fix error and no emit" ,
203+ modifyFs : fs => replaceText ( fs , "/src/project/src/class.ts" , "prop1" , "prop" ) ,
204+ buildKind : BuildKind . IncrementalDtsChange
205+ } ,
206+ noChangeRunWithEmit ,
207+ ] ,
208+ } ) ;
209+
210+ function fs ( ) {
211+ return loadProjectFromFiles ( {
212+ "/src/project/src/class.ts" : Utils . dedent `
213+ export class classC {
214+ prop = 1;
215+ }` ,
216+ "/src/project/src/indirectClass.ts" : Utils . dedent `
217+ import { classC } from './class';
218+ export class indirectClass {
219+ classC = new classC();
220+ }` ,
221+ "/src/project/src/directUse.ts" : Utils . dedent `
222+ import { indirectClass } from './indirectClass';
223+ new indirectClass().classC.prop;` ,
224+ "/src/project/src/indirectUse.ts" : Utils . dedent `
225+ import { indirectClass } from './indirectClass';
226+ new indirectClass().classC.prop;` ,
227+ "/src/project/src/noChangeFile.ts" : Utils . dedent `
228+ export function writeLog(s: string) {
229+ }` ,
230+ "/src/project/src/noChangeFileWithEmitSpecificError.ts" : Utils . dedent `
231+ function someFunc(arguments: boolean, ...rest: any[]) {
232+ }` ,
233+ "/src/project/tsconfig.json" : JSON . stringify ( { compilerOptions } ) ,
234+ } ) ;
235+ }
236+ }
237+ } ) ;
119238 } ) ;
120239}
0 commit comments