mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-06 06:49:29 -05:00
add action for enabling experimentalDescorators option in user config… (#30484)
* add action for enabling experimentalDescorators option in user config file, change error message for this case #29035 * add missing changes in tests * Add "experimental decorators" tests for jsconfig file
This commit is contained in:
committed by
Ryan Cavanaugh
parent
b8e3c41ee1
commit
5b79b942e8
@@ -25636,7 +25636,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!compilerOptions.experimentalDecorators) {
|
||||
error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning);
|
||||
error(node, 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);
|
||||
}
|
||||
|
||||
const firstDecorator = node.decorators[0];
|
||||
|
||||
@@ -691,7 +691,7 @@
|
||||
"category": "Error",
|
||||
"code": 1218
|
||||
},
|
||||
"Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.": {
|
||||
"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.": {
|
||||
"category": "Error",
|
||||
"code": 1219
|
||||
},
|
||||
|
||||
@@ -1816,7 +1816,7 @@ namespace ts {
|
||||
|
||||
function walkArray(nodes: NodeArray<Node>) {
|
||||
if (parent.decorators === nodes && !options.experimentalDecorators) {
|
||||
diagnostics.push(createDiagnosticForNode(parent, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning));
|
||||
diagnostics.push(createDiagnosticForNode(parent, 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));
|
||||
}
|
||||
|
||||
switch (parent.kind) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace ts.codefix {
|
||||
const fixId = "enableExperimentalDecorators";
|
||||
const errorCodes = [
|
||||
Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning.code
|
||||
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
|
||||
];
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
@@ -12,13 +12,20 @@ namespace ts.codefix {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const changes = textChanges.ChangeTracker.with(context, changeTracker => makeChange(changeTracker, configFile));
|
||||
const changes = textChanges.ChangeTracker.with(context, changeTracker => doChange(changeTracker, configFile));
|
||||
return [createCodeFixActionNoFixId(fixId, changes, Diagnostics.Enable_the_experimentalDecorators_option_in_your_configuration_file)];
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes) => {
|
||||
const { configFile } = context.program.getCompilerOptions();
|
||||
if (configFile === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
doChange(changes, configFile);
|
||||
}),
|
||||
});
|
||||
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) {
|
||||
function doChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) {
|
||||
setJsonCompilerOptionValue(changeTracker, configFile, "experimentalDecorators", createTrue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user