Implement the Stage 3 Decorators Proposal (#50820)

This commit is contained in:
Ron Buckton
2023-01-19 17:54:12 -05:00
committed by GitHub
parent 20182cf848
commit 5b18979697
1263 changed files with 31412 additions and 2813 deletions

View File

@@ -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";

View File

@@ -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());
}

View File

@@ -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(