Skip to content
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

Fixes for decorators property deprecations #50343

Merged
merged 6 commits into from Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Expand Up @@ -44015,7 +44015,7 @@ namespace ts {
}

function checkGrammarDecorators(node: Node): boolean {
if (canHaveIllegalDecorators(node) && some(node.decorators)) {
if (canHaveIllegalDecorators(node) && some(node._decorators)) {
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
}
if (!canHaveDecorators(node) || !hasDecorators(node)) {
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/debug.ts
Expand Up @@ -30,6 +30,7 @@ namespace ts {
export let currentLogLevel = LogLevel.Warning;
export let isDebugging = false;
export let loggingHost: LoggingHost | undefined;
export let enableDeprecationWarnings = true;
/* eslint-enable prefer-const */

type AssertionKeys = MatchingKeys<typeof Debug, AnyFunction>;
Expand Down Expand Up @@ -732,7 +733,7 @@ namespace ts {
function createWarningDeprecation(name: string, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) {
let hasWrittenDeprecation = false;
return () => {
if (!hasWrittenDeprecation) {
if (enableDeprecationWarnings && !hasWrittenDeprecation) {
log.warn(formatDeprecationMessage(name, /*error*/ false, errorAfter, since, message));
hasWrittenDeprecation = true;
}
Expand Down
56 changes: 28 additions & 28 deletions src/compiler/factory/nodeFactory.ts
Expand Up @@ -1435,7 +1435,7 @@ namespace ts {
node.transformFlags = propagateChildFlags(body) | TransformFlags.ContainsClassFields;

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
node.modifiers = undefined;
return node;
}
Expand All @@ -1452,7 +1452,7 @@ namespace ts {

function finishUpdateClassStaticBlockDeclaration(updated: Mutable<ClassStaticBlockDeclaration>, original: ClassStaticBlockDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
updated.modifiers = original.modifiers;
}
return update(updated, original);
Expand All @@ -1476,7 +1476,7 @@ namespace ts {
node.transformFlags |= TransformFlags.ContainsES2015;

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
node.typeParameters = undefined;
node.type = undefined;
return node;
Expand All @@ -1498,7 +1498,7 @@ namespace ts {

function finishUpdateConstructorDeclaration(updated: Mutable<ConstructorDeclaration>, original: ConstructorDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
updated.typeParameters = original.typeParameters;
updated.type = original.type;
}
Expand Down Expand Up @@ -3657,7 +3657,7 @@ namespace ts {
}

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand Down Expand Up @@ -3686,7 +3686,7 @@ namespace ts {
function finishUpdateFunctionDeclaration(updated: Mutable<FunctionDeclaration>, original: FunctionDeclaration) {
if (updated !== original) {
// copy children used only for error reporting
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return finishUpdateBaseSignatureDeclaration(updated, original);
}
Expand Down Expand Up @@ -3756,7 +3756,7 @@ namespace ts {
node.transformFlags = TransformFlags.ContainsTypeScript;

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -3780,7 +3780,7 @@ namespace ts {

function finishUpdateInterfaceDeclaration(updated: Mutable<InterfaceDeclaration>, original: InterfaceDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand All @@ -3802,7 +3802,7 @@ namespace ts {
node.transformFlags = TransformFlags.ContainsTypeScript;

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -3824,7 +3824,7 @@ namespace ts {

function finishUpdateTypeAliasDeclaration(updated: Mutable<TypeAliasDeclaration>, original: TypeAliasDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand All @@ -3847,7 +3847,7 @@ namespace ts {
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Enum declarations cannot contain `await`

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -3866,7 +3866,7 @@ namespace ts {

function finishUpdateEnumDeclaration(updated: Mutable<EnumDeclaration>, original: EnumDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand Down Expand Up @@ -3896,7 +3896,7 @@ namespace ts {
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Module declarations cannot contain `await`.

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -3916,7 +3916,7 @@ namespace ts {

function finishUpdateModuleDeclaration(updated: Mutable<ModuleDeclaration>, original: ModuleDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand Down Expand Up @@ -3961,7 +3961,7 @@ namespace ts {
node.transformFlags = TransformFlags.ContainsTypeScript;

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
node.modifiers = undefined;
return node;
}
Expand All @@ -3975,7 +3975,7 @@ namespace ts {

function finishUpdateNamespaceExportDeclaration(updated: Mutable<NamespaceExportDeclaration>, original: NamespaceExportDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
updated.modifiers = original.modifiers;
}
return update(updated, original);
Expand All @@ -4000,7 +4000,7 @@ namespace ts {
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Import= declaration is always parsed in an Await context

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -4022,7 +4022,7 @@ namespace ts {

function finishUpdateImportEqualsDeclaration(updated: Mutable<ImportEqualsDeclaration>, original: ImportEqualsDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand All @@ -4045,7 +4045,7 @@ namespace ts {
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -4067,7 +4067,7 @@ namespace ts {

function finishUpdateImportDeclaration(updated: Mutable<ImportDeclaration>, original: ImportDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand Down Expand Up @@ -4235,7 +4235,7 @@ namespace ts {
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -4253,7 +4253,7 @@ namespace ts {

function finishUpdateExportAssignment(updated: Mutable<ExportAssignment>, original: ExportAssignment) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand All @@ -4279,7 +4279,7 @@ namespace ts {
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
return node;
}

Expand All @@ -4303,7 +4303,7 @@ namespace ts {

function finishUpdateExportDeclaration(updated: Mutable<ExportDeclaration>, original: ExportDeclaration) {
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
}
return update(updated, original);
}
Expand Down Expand Up @@ -5162,7 +5162,7 @@ namespace ts {
propagateChildFlags(node.initializer);

// The following properties are used only to report grammar errors
node.decorators = undefined;
node._decorators = undefined;
node.modifiers = undefined;
node.questionToken = undefined;
node.exclamationToken = undefined;
Expand All @@ -5180,7 +5180,7 @@ namespace ts {
function finishUpdatePropertyAssignment(updated: Mutable<PropertyAssignment>, original: PropertyAssignment) {
// copy children used only for error reporting
if (updated !== original) {
updated.decorators = original.decorators;
updated._decorators = original._decorators;
updated.modifiers = original.modifiers;
updated.questionToken = original.questionToken;
updated.exclamationToken = original.exclamationToken;
Expand All @@ -5202,7 +5202,7 @@ namespace ts {

// The following properties are used only to report grammar errors
node.equalsToken = undefined;
node.decorators = undefined;
node._decorators = undefined;
node.modifiers = undefined;
node.questionToken = undefined;
node.exclamationToken = undefined;
Expand All @@ -5221,7 +5221,7 @@ namespace ts {
if (updated !== original) {
// copy children used only for error reporting
updated.equalsToken = original.equalsToken;
updated.decorators = original.decorators;
updated._decorators = original._decorators;
updated.modifiers = original.modifiers;
updated.questionToken = original.questionToken;
updated.exclamationToken = original.exclamationToken;
Expand Down