@@ -4307,17 +4307,23 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
4307
4307
}
4308
4308
}
4309
4309
4310
- function verifyDeprecatedCompilerOptions ( ) {
4310
+ function getVersionForDeprecationDiagnostics ( reportInvalidIgnoreDeprecations : boolean ) {
4311
4311
const version = typeScriptVersion || versionMajorMinor ;
4312
4312
const ignoreDeprecations = options . ignoreDeprecations ;
4313
4313
if ( ignoreDeprecations ) {
4314
4314
if ( ignoreDeprecations === DeprecationVersion . v5_0 && ( version === DeprecationVersion . v5_0 || version === DeprecationVersion . v5_5 ) ) {
4315
4315
return ;
4316
4316
}
4317
- else {
4317
+ else if ( reportInvalidIgnoreDeprecations ) {
4318
4318
createOptionValueDiagnostic ( "ignoreDeprecations" , Diagnostics . Invalid_value_for_ignoreDeprecations ) ;
4319
4319
}
4320
4320
}
4321
+ return version ;
4322
+ }
4323
+
4324
+ function verifyDeprecatedCompilerOptions ( ) {
4325
+ const version = getVersionForDeprecationDiagnostics ( /*reportInvalidIgnoreDeprecations*/ true ) ;
4326
+ if ( ! version ) return ;
4321
4327
if ( options . target === ScriptTarget . ES3 ) {
4322
4328
createDeprecatedDiagnosticForOption ( version , "target" , "ES3" ) ;
4323
4329
}
@@ -4350,27 +4356,47 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
4350
4356
}
4351
4357
}
4352
4358
4359
+ function verifyDeprecatedProjectReference ( ref : ProjectReference , parentFile : JsonSourceFile | undefined , index : number ) {
4360
+ if ( ref . prepend ) {
4361
+ const version = getVersionForDeprecationDiagnostics ( /*reportInvalidIgnoreDeprecations*/ false ) ;
4362
+ if ( version ) {
4363
+ createDeprecatedOptionForVersionDiagnostic (
4364
+ version ,
4365
+ ( message , arg0 , arg1 , arg2 ) => createDiagnosticForReference ( parentFile , index , message , arg0 , arg1 , arg2 ) ,
4366
+ "prepend" ,
4367
+ ) ;
4368
+ }
4369
+ }
4370
+ }
4371
+
4353
4372
function createDeprecatedDiagnosticForOption ( version : string , name : string , value ?: string , useInstead ?: string ) {
4373
+ return createDeprecatedOptionForVersionDiagnostic (
4374
+ version ,
4375
+ ( message , arg0 , arg1 , arg2 ) => {
4376
+ if ( useInstead ) {
4377
+ const details = chainDiagnosticMessages ( /*details*/ undefined , Diagnostics . Use_0_instead , useInstead ) ;
4378
+ const chain = chainDiagnosticMessages ( details , message , arg0 , arg1 , arg2 ) ;
4379
+ createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined , chain ) ;
4380
+ }
4381
+ else {
4382
+ createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined , message , arg0 , arg1 , arg2 ) ;
4383
+ }
4384
+ } ,
4385
+ name ,
4386
+ value ,
4387
+ ) ;
4388
+ }
4389
+
4390
+ function createDeprecatedOptionForVersionDiagnostic (
4391
+ version : string ,
4392
+ createDiagnostic : ( message : DiagnosticMessage , arg0 : string , arg1 ?: string , arg2 ?: string ) => void ,
4393
+ name : string ,
4394
+ value ?: string ) {
4354
4395
if ( version === DeprecationVersion . v6_0 ) {
4355
- if ( useInstead ) {
4356
- const details = chainDiagnosticMessages ( /*details*/ undefined , Diagnostics . Use_0_instead , useInstead ) ;
4357
- const chain = chainDiagnosticMessages ( details , Diagnostics . Flag_0_is_deprecated_Please_remove_it_from_your_configuration , value || name ) ;
4358
- createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined , chain ) ;
4359
- }
4360
- else {
4361
- createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined , Diagnostics . Flag_0_is_deprecated_Please_remove_it_from_your_configuration , value || name ) ;
4362
- }
4396
+ createDiagnostic ( Diagnostics . Flag_0_is_deprecated_Please_remove_it_from_your_configuration , value || name ) ;
4363
4397
}
4364
4398
else {
4365
- if ( useInstead ) {
4366
- const details = chainDiagnosticMessages ( /*details*/ undefined , Diagnostics . Use_0_instead , useInstead ) ;
4367
- const chain = chainDiagnosticMessages ( details , Diagnostics . Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_ignoreDeprecations_Colon_2_to_silence_this_error , value || name , DeprecationVersion . v5_5 , DeprecationVersion . v5_0 ) ;
4368
- createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined , chain ) ;
4369
- }
4370
- else {
4371
- createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined ,
4372
- Diagnostics . Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_ignoreDeprecations_Colon_2_to_silence_this_error , value || name , DeprecationVersion . v5_5 , DeprecationVersion . v5_0 ) ;
4373
- }
4399
+ createDiagnostic ( Diagnostics . Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_ignoreDeprecations_Colon_2_to_silence_this_error , value || name , DeprecationVersion . v5_5 , DeprecationVersion . v5_0 ) ;
4374
4400
}
4375
4401
}
4376
4402
@@ -4514,6 +4540,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
4514
4540
forEachProjectReference ( projectReferences , resolvedProjectReferences , ( resolvedRef , parent , index ) => {
4515
4541
const ref = ( parent ? parent . commandLine . projectReferences : projectReferences ) ! [ index ] ;
4516
4542
const parentFile = parent && parent . sourceFile as JsonSourceFile ;
4543
+ verifyDeprecatedProjectReference ( ref , parentFile , index ) ;
4517
4544
if ( ! resolvedRef ) {
4518
4545
createDiagnosticForReference ( parentFile , index , Diagnostics . File_0_not_found , ref . path ) ;
4519
4546
return ;
@@ -4608,14 +4635,14 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
4608
4635
createDiagnosticForOption ( /*onKey*/ false , option1 , /*option2*/ undefined , message , arg0 , arg1 ) ;
4609
4636
}
4610
4637
4611
- function createDiagnosticForReference ( sourceFile : JsonSourceFile | undefined , index : number , message : DiagnosticMessage , arg0 ?: string | number , arg1 ?: string | number ) {
4638
+ function createDiagnosticForReference ( sourceFile : JsonSourceFile | undefined , index : number , message : DiagnosticMessage , arg0 ?: string | number , arg1 ?: string | number , arg2 ?: string | number ) {
4612
4639
const referencesSyntax = firstDefined ( getTsConfigPropArray ( sourceFile || options . configFile , "references" ) ,
4613
4640
property => isArrayLiteralExpression ( property . initializer ) ? property . initializer : undefined ) ;
4614
4641
if ( referencesSyntax && referencesSyntax . elements . length > index ) {
4615
- programDiagnostics . add ( createDiagnosticForNodeInSourceFile ( sourceFile || options . configFile ! , referencesSyntax . elements [ index ] , message , arg0 , arg1 ) ) ;
4642
+ programDiagnostics . add ( createDiagnosticForNodeInSourceFile ( sourceFile || options . configFile ! , referencesSyntax . elements [ index ] , message , arg0 , arg1 , arg2 ) ) ;
4616
4643
}
4617
4644
else {
4618
- programDiagnostics . add ( createCompilerDiagnostic ( message , arg0 , arg1 ) ) ;
4645
+ programDiagnostics . add ( createCompilerDiagnostic ( message , arg0 , arg1 , arg2 ) ) ;
4619
4646
}
4620
4647
}
4621
4648
0 commit comments