• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* @internal */
2namespace ts.codefix {
3    const fixId = "enableExperimentalDecorators";
4    const errorCodes = [
5        Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning.code
6    ];
7    registerCodeFix({
8        errorCodes,
9        getCodeActions: function getCodeActionsToEnableExperimentalDecorators(context) {
10            const { configFile } = context.program.getCompilerOptions();
11            if (configFile === undefined) {
12                return undefined;
13            }
14
15            const changes = textChanges.ChangeTracker.with(context, changeTracker => doChange(changeTracker, configFile));
16            return [createCodeFixActionWithoutFixAll(fixId, changes, Diagnostics.Enable_the_experimentalDecorators_option_in_your_configuration_file)];
17        },
18        fixIds: [fixId],
19        getAllCodeActions: context => codeFixAll(context, errorCodes, (changes) => {
20            const { configFile } = context.program.getCompilerOptions();
21            if (configFile === undefined) {
22                return undefined;
23            }
24            doChange(changes, configFile);
25        }),
26    });
27
28    function doChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) {
29        setJsonCompilerOptionValue(changeTracker, configFile, "experimentalDecorators", factory.createTrue());
30    }
31}
32