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

🤖 Pick PR #50343 (Fixes for decorators property dep...) into release-4.8 #50374

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

function checkGrammarDecorators(node: Node): boolean {
if (canHaveIllegalDecorators(node) && some(node.decorators)) {
if (canHaveIllegalDecorators(node) && some(node.illegalDecorators)) {
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = 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.illegalDecorators = original.illegalDecorators;
}
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.illegalDecorators = undefined;
return node;
}

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