mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 02:21:30 -05:00
Implement the Stage 3 Decorators Proposal (#50820)
This commit is contained in:
@@ -34,7 +34,6 @@ export * from "../codefixes/fixCannotFindModule";
|
||||
export * from "../codefixes/fixClassDoesntImplementInheritedAbstractMember";
|
||||
export * from "../codefixes/fixClassSuperMustPrecedeThisAccess";
|
||||
export * from "../codefixes/fixConstructorForDerivedNeedSuperCall";
|
||||
export * from "../codefixes/fixEnableExperimentalDecorators";
|
||||
export * from "../codefixes/fixEnableJsxFlag";
|
||||
export * from "../codefixes/fixNaNEquality";
|
||||
export * from "../codefixes/fixModuleAndTargetOptions";
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import {
|
||||
Diagnostics,
|
||||
factory,
|
||||
textChanges,
|
||||
TsConfigSourceFile,
|
||||
} from "../_namespaces/ts";
|
||||
import {
|
||||
codeFixAll,
|
||||
createCodeFixActionWithoutFixAll,
|
||||
registerCodeFix,
|
||||
setJsonCompilerOptionValue,
|
||||
} from "../_namespaces/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_in_your_tsconfig_or_jsconfig_to_remove_this_warning.code
|
||||
];
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions: function getCodeActionsToEnableExperimentalDecorators(context) {
|
||||
const { configFile } = context.program.getCompilerOptions();
|
||||
if (configFile === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const changes = textChanges.ChangeTracker.with(context, changeTracker => doChange(changeTracker, configFile));
|
||||
return [createCodeFixActionWithoutFixAll(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 doChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) {
|
||||
setJsonCompilerOptionValue(changeTracker, configFile, "experimentalDecorators", factory.createTrue());
|
||||
}
|
||||
@@ -213,7 +213,7 @@ function generateGetAccessor(fieldName: AcceptedNameType, accessorName: Accepted
|
||||
return factory.createGetAccessorDeclaration(
|
||||
modifiers,
|
||||
accessorName,
|
||||
/*parameters*/ undefined!, // TODO: GH#18217
|
||||
[],
|
||||
type,
|
||||
factory.createBlock([
|
||||
factory.createReturnStatement(
|
||||
|
||||
Reference in New Issue
Block a user