@@ -1021,12 +1021,11 @@ namespace ts {
1021
1021
* @param configFileParsingDiagnostics - error during config file parsing
1022
1022
* @returns A 'Program' object.
1023
1023
*/
1024
- export function createProgram ( rootNames : readonly string [ ] , options : CompilerOptions , host ?: CompilerHost , oldProgram ?: Program , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program ;
1025
- export function createProgram ( rootNamesOrOptions : readonly string [ ] | CreateProgramOptions , _options ?: CompilerOptions , _host ?: CompilerHost , _oldProgram ?: Program , _configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program {
1024
+ export function createProgram ( rootNames : readonly string [ ] , options : CompilerOptions , host ?: CompilerHost , oldProgram ?: Program , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , typeScriptVersion ?: string ) : Program ;
1025
+ export function createProgram ( rootNamesOrOptions : readonly string [ ] | CreateProgramOptions , _options ?: CompilerOptions , _host ?: CompilerHost , _oldProgram ?: Program , _configFileParsingDiagnostics ?: readonly Diagnostic [ ] , typeScriptVersion ?: string ) : Program {
1026
1026
const createProgramOptions = isArray ( rootNamesOrOptions ) ? createCreateProgramOptions ( rootNamesOrOptions , _options ! , _host , _oldProgram , _configFileParsingDiagnostics ) : rootNamesOrOptions ; // TODO: GH#18217
1027
1027
const { rootNames, options, configFileParsingDiagnostics, projectReferences } = createProgramOptions ;
1028
1028
let { oldProgram } = createProgramOptions ;
1029
-
1030
1029
let processingDefaultLibFiles : SourceFile [ ] | undefined ;
1031
1030
let processingOtherFiles : SourceFile [ ] | undefined ;
1032
1031
let files : SourceFile [ ] ;
@@ -1073,6 +1072,9 @@ namespace ts {
1073
1072
const supportedExtensions = getSupportedExtensions ( options ) ;
1074
1073
const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule ( options , supportedExtensions ) ;
1075
1074
1075
+ let _typeScriptVersion : Version | undefined ;
1076
+ const _ignoreDeprecations = new Map < DeprecationPhase , Version > ( ) ;
1077
+
1076
1078
// Map storing if there is emit blocking diagnostics for given input
1077
1079
const hasEmitBlockingDiagnostics = new Map < string , boolean > ( ) ;
1078
1080
let _compilerOptionsObjectLiteralSyntax : ObjectLiteralExpression | false | undefined ;
@@ -3397,6 +3399,7 @@ namespace ts {
3397
3399
if ( options . strictPropertyInitialization && ! getStrictOptionValue ( options , "strictNullChecks" ) ) {
3398
3400
createDiagnosticForOptionName ( Diagnostics . Option_0_cannot_be_specified_without_specifying_option_1 , "strictPropertyInitialization" , "strictNullChecks" ) ;
3399
3401
}
3402
+
3400
3403
if ( options . exactOptionalPropertyTypes && ! getStrictOptionValue ( options , "strictNullChecks" ) ) {
3401
3404
createDiagnosticForOptionName ( Diagnostics . Option_0_cannot_be_specified_without_specifying_option_1 , "exactOptionalPropertyTypes" , "strictNullChecks" ) ;
3402
3405
}
@@ -3439,6 +3442,7 @@ namespace ts {
3439
3442
programDiagnostics . add ( createCompilerDiagnostic ( Diagnostics . Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified ) ) ;
3440
3443
}
3441
3444
3445
+ verifyDeprecatedCompilerOptions ( ) ;
3442
3446
verifyProjectReferences ( ) ;
3443
3447
3444
3448
// List of collected files is complete; validate exhautiveness if this is a project with a file list
@@ -3701,6 +3705,55 @@ namespace ts {
3701
3705
}
3702
3706
}
3703
3707
3708
+ function verifyDeprecatedCompilerOptions ( ) {
3709
+ const version = isString ( typeScriptVersion ) && typeScriptVersion ? new Version ( typeScriptVersion ) : getTypeScriptVersion ( ) ;
3710
+ if ( options . ignoreDeprecations ) {
3711
+ const ignoreDeprecationsVersion = getIgnoreDeprecationsVersion ( options . ignoreDeprecations ) ;
3712
+ if ( ignoreDeprecationsVersion . compareTo ( version ) === Comparison . LessThan ) {
3713
+ createOptionValueDiagnostic ( "ignoreDeprecations" , Diagnostics . Invalid_value_for_ignoreDeprecations ) ;
3714
+ }
3715
+ if ( ignoreDeprecationsVersion . compareTo ( version ) >= 0 ) {
3716
+ return ;
3717
+ }
3718
+ }
3719
+ if ( options . target === ScriptTarget . ES3 ) {
3720
+ createDeprecatedDiagnosticForOption ( version , "target" , "ES3" ) ;
3721
+ }
3722
+ if ( options . noImplicitUseStrict ) {
3723
+ createDeprecatedDiagnosticForOption ( version , "noImplicitUseStrict" ) ;
3724
+ }
3725
+ if ( options . keyofStringsOnly ) {
3726
+ createDeprecatedDiagnosticForOption ( version , "keyofStringsOnly" ) ;
3727
+ }
3728
+ if ( options . suppressExcessPropertyErrors ) {
3729
+ createDeprecatedDiagnosticForOption ( version , "suppressExcessPropertyErrors" ) ;
3730
+ }
3731
+ if ( options . suppressImplicitAnyIndexErrors ) {
3732
+ createDeprecatedDiagnosticForOption ( version , "suppressImplicitAnyIndexErrors" ) ;
3733
+ }
3734
+ if ( options . noStrictGenericChecks ) {
3735
+ createDeprecatedDiagnosticForOption ( version , "noStrictGenericChecks" ) ;
3736
+ }
3737
+ if ( options . charset ) {
3738
+ createDeprecatedDiagnosticForOption ( version , "charset" ) ;
3739
+ }
3740
+ if ( options . out ) {
3741
+ createDeprecatedDiagnosticForOption ( version , "out" ) ;
3742
+ }
3743
+ }
3744
+
3745
+ function createDeprecatedDiagnosticForOption ( version : Version , name : string , value ?: string ) {
3746
+ if ( version . compareTo ( getIgnoreDeprecationsVersion ( DeprecationPhase . Phase3 ) ) === Comparison . EqualTo ) {
3747
+ createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined , Diagnostics . Flag_0_is_deprecated_please_remove_it_from_your_configuration , value || name ) ;
3748
+ }
3749
+ else {
3750
+ const { major, minor } = version ;
3751
+ const nextPhase = version . compareTo ( getIgnoreDeprecationsVersion ( DeprecationPhase . Phase2 ) ) === Comparison . EqualTo ? DeprecationPhase . Phase3 : DeprecationPhase . Phase2 ;
3752
+ createDiagnosticForOption ( /*onKey*/ ! value , name , /*option2*/ undefined ,
3753
+ Diagnostics . Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_ignoreDeprecations_Colon_2_to_silence_this_error , value || name , DeprecationPhaseToVersionMap [ nextPhase ] , `${ major } .${ minor } ` ) ;
3754
+ }
3755
+ }
3756
+
3704
3757
function createDiagnosticExplainingFile ( file : SourceFile | undefined , fileProcessingReason : FileIncludeReason | undefined , diagnostic : DiagnosticMessage , args : ( string | number | undefined ) [ ] | undefined ) : Diagnostic {
3705
3758
let fileIncludeReasons : DiagnosticMessageChain [ ] | undefined ;
3706
3759
let relatedInfo : Diagnostic [ ] | undefined ;
@@ -3972,6 +4025,21 @@ namespace ts {
3972
4025
return _compilerOptionsObjectLiteralSyntax || undefined ;
3973
4026
}
3974
4027
4028
+ function getTypeScriptVersion ( ) {
4029
+ if ( _typeScriptVersion === undefined ) {
4030
+ _typeScriptVersion = new Version ( versionMajorMinor ) ;
4031
+ }
4032
+ return _typeScriptVersion ;
4033
+ }
4034
+
4035
+ function getIgnoreDeprecationsVersion ( phase : DeprecationPhase ) {
4036
+ let version = _ignoreDeprecations . get ( phase ) ;
4037
+ if ( version === undefined ) {
4038
+ _ignoreDeprecations . set ( phase , version = new Version ( DeprecationPhaseToVersionMap [ phase ] ) ) ;
4039
+ }
4040
+ return version ;
4041
+ }
4042
+
3975
4043
function createOptionDiagnosticInObjectLiteralSyntax ( objectLiteral : ObjectLiteralExpression , onKey : boolean , key1 : string , key2 : string | undefined , message : DiagnosticMessage , arg0 ?: string | number , arg1 ?: string | number , arg2 ?: string | number ) : boolean {
3976
4044
const props = getPropertyAssignment ( objectLiteral , key1 , key2 ) ;
3977
4045
for ( const prop of props ) {
0 commit comments