-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Rename typingOptions.enableAutoDiscovery to typeAcquisition.enable #12373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -462,11 +462,18 @@ namespace ts { | |
| ]; | ||
|
|
||
| /* @internal */ | ||
| export let typingOptionDeclarations: CommandLineOption[] = [ | ||
| export let typeAcquisitionDeclarations: CommandLineOption[] = [ | ||
| { | ||
| /* @deprecated typingOptions.enableAutoDiscovery | ||
| * Use typeAcquisition.enable instead. | ||
| */ | ||
| name: "enableAutoDiscovery", | ||
| type: "boolean", | ||
| }, | ||
| { | ||
| name: "enable", | ||
| type: "boolean", | ||
| }, | ||
| { | ||
| name: "include", | ||
| type: "list", | ||
|
|
@@ -501,6 +508,20 @@ namespace ts { | |
|
|
||
| let optionNameMapCache: OptionNameMap; | ||
|
|
||
| /* @internal */ | ||
| export function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition { | ||
| // Convert deprecated typingOptions.enableAutoDiscovery to typeAcquisition.enable | ||
| if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) { | ||
| const result: TypeAcquisition = { | ||
| enable: typeAcquisition.enableAutoDiscovery, | ||
| include: typeAcquisition.include || [], | ||
| exclude: typeAcquisition.exclude || [] | ||
| }; | ||
| return result; | ||
| } | ||
| return typeAcquisition; | ||
| } | ||
|
|
||
| /* @internal */ | ||
| export function getOptionNameMap(): OptionNameMap { | ||
| if (optionNameMapCache) { | ||
|
|
@@ -835,15 +856,18 @@ namespace ts { | |
| return { | ||
| options: {}, | ||
| fileNames: [], | ||
| typingOptions: {}, | ||
| typeAcquisition: {}, | ||
| raw: json, | ||
| errors: [createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))], | ||
| wildcardDirectories: {} | ||
| }; | ||
| } | ||
|
|
||
| let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); | ||
| const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); | ||
| // typingOptions has been deprecated and is only supported for backward compatibility purposes. | ||
| // It should be removed in future releases - use typeAcquisition instead. | ||
| const jsonOptions = json["typeAcquisition"] || json["typingOptions"]; | ||
| const typeAcquisition: TypeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); | ||
|
|
||
| if (json["extends"]) { | ||
| let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}]; | ||
|
|
@@ -874,7 +898,7 @@ namespace ts { | |
| return { | ||
| options, | ||
| fileNames, | ||
| typingOptions, | ||
| typeAcquisition, | ||
| raw: json, | ||
| errors, | ||
| wildcardDirectories, | ||
|
|
@@ -996,9 +1020,9 @@ namespace ts { | |
| return { options, errors }; | ||
| } | ||
|
|
||
| export function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypingOptions, errors: Diagnostic[] } { | ||
| export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition, errors: Diagnostic[] } { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question to @mhegazy - do we consider this a breaking change since this API was public in 2.0. this is also related to name of section in config file
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we never documented it intentionally , i would say. so it is a breaking change, but not one that would impact ppl.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding support for the deprecated API (typingOptions.enableAutoDiscovery) just in case |
||
| const errors: Diagnostic[] = []; | ||
| const options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); | ||
| const options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); | ||
| return { options, errors }; | ||
| } | ||
|
|
||
|
|
@@ -1012,16 +1036,18 @@ namespace ts { | |
| return options; | ||
| } | ||
|
|
||
| function convertTypingOptionsFromJsonWorker(jsonOptions: any, | ||
| basePath: string, errors: Diagnostic[], configFileName?: string): TypingOptions { | ||
| function convertTypeAcquisitionFromJsonWorker(jsonOptions: any, | ||
| basePath: string, errors: Diagnostic[], configFileName?: string): TypeAcquisition { | ||
|
|
||
| const options: TypeAcquisition = { enable: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; | ||
| const typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions); | ||
| convertOptionsFromJson(typeAcquisitionDeclarations, typeAcquisition, basePath, options, Diagnostics.Unknown_type_acquisition_option_0, errors); | ||
|
|
||
| const options: TypingOptions = { enableAutoDiscovery: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; | ||
| convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors); | ||
| return options; | ||
| } | ||
|
|
||
| function convertOptionsFromJson(optionDeclarations: CommandLineOption[], jsonOptions: any, basePath: string, | ||
| defaultOptions: CompilerOptions | TypingOptions, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) { | ||
| defaultOptions: CompilerOptions | TypeAcquisition, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) { | ||
|
|
||
| if (!jsonOptions) { | ||
| return; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment that we support
typingOptionsonly for backward compat purposes and should remove it in a couple of releases