@@ -4307,17 +4307,23 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
43074307 }
43084308 }
43094309
4310- function verifyDeprecatedCompilerOptions ( ) {
4310+ function getVersionForDeprecationDiagnostics ( reportInvalidIgnoreDeprecations : boolean ) {
43114311 const version = typeScriptVersion || versionMajorMinor ;
43124312 const ignoreDeprecations = options . ignoreDeprecations ;
43134313 if ( ignoreDeprecations ) {
43144314 if ( ignoreDeprecations === DeprecationVersion . v5_0 && ( version === DeprecationVersion . v5_0 || version === DeprecationVersion . v5_5 ) ) {
43154315 return ;
43164316 }
4317- else {
4317+ else if ( reportInvalidIgnoreDeprecations ) {
43184318 createOptionValueDiagnostic ( "ignoreDeprecations" , Diagnostics . Invalid_value_for_ignoreDeprecations ) ;
43194319 }
43204320 }
4321+ return version ;
4322+ }
4323+
4324+ function verifyDeprecatedCompilerOptions ( ) {
4325+ const version = getVersionForDeprecationDiagnostics ( /*reportInvalidIgnoreDeprecations*/ true ) ;
4326+ if ( ! version ) return ;
43214327 if ( options . target === ScriptTarget . ES3 ) {
43224328 createDeprecatedDiagnosticForOption ( version , "target" , "ES3" ) ;
43234329 }
@@ -4350,27 +4356,47 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
43504356 }
43514357 }
43524358
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+
43534372 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 ) {
43544395 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 ) ;
43634397 }
43644398 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 ) ;
43744400 }
43754401 }
43764402
@@ -4514,6 +4540,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
45144540 forEachProjectReference ( projectReferences , resolvedProjectReferences , ( resolvedRef , parent , index ) => {
45154541 const ref = ( parent ? parent . commandLine . projectReferences : projectReferences ) ! [ index ] ;
45164542 const parentFile = parent && parent . sourceFile as JsonSourceFile ;
4543+ verifyDeprecatedProjectReference ( ref , parentFile , index ) ;
45174544 if ( ! resolvedRef ) {
45184545 createDiagnosticForReference ( parentFile , index , Diagnostics . File_0_not_found , ref . path ) ;
45194546 return ;
@@ -4608,14 +4635,14 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
46084635 createDiagnosticForOption ( /*onKey*/ false , option1 , /*option2*/ undefined , message , arg0 , arg1 ) ;
46094636 }
46104637
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 ) {
46124639 const referencesSyntax = firstDefined ( getTsConfigPropArray ( sourceFile || options . configFile , "references" ) ,
46134640 property => isArrayLiteralExpression ( property . initializer ) ? property . initializer : undefined ) ;
46144641 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 ) ) ;
46164643 }
46174644 else {
4618- programDiagnostics . add ( createCompilerDiagnostic ( message , arg0 , arg1 ) ) ;
4645+ programDiagnostics . add ( createCompilerDiagnostic ( message , arg0 , arg1 , arg2 ) ) ;
46194646 }
46204647 }
46214648
0 commit comments