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

Fix deprecatedCompat create/updateConstructorDeclaration functions #50260

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/deprecatedCompat/4.8/mergeDecoratorsAndModifiers.ts
Expand Up @@ -535,7 +535,7 @@ namespace ts {
(decorators === undefined || !some(decorators, isModifier)) &&
(modifiers === undefined || !some(modifiers, isParameter)) &&
(parameters === undefined || isArray(parameters)) &&
(body === undefined || !isBlock(body)),
(body === undefined || isBlock(body)),
})
.deprecate({
1: DISALLOW_DECORATORS
Expand Down Expand Up @@ -563,7 +563,7 @@ namespace ts {
(decorators === undefined || !some(decorators, isModifier)) &&
(modifiers === undefined || !some(modifiers, isParameter)) &&
(parameters === undefined || isArray(parameters)) &&
(body === undefined || !isBlock(body)),
(body === undefined || isBlock(body)),
})
.deprecate({
1: DISALLOW_DECORATORS
Expand Down
23 changes: 23 additions & 0 deletions src/testRunner/unittests/factory.ts
Expand Up @@ -81,5 +81,28 @@ namespace ts {
checkRhs(SyntaxKind.QuestionQuestionEqualsToken, /*expectParens*/ false);
});
});

describe("deprecatedCompat/mergeDecoratorsAndModifiers", () => {
it("supports deprecated createConstructorDeclaration/updateConstructorDeclaration functions", () => {
const body = factory.createBlock([]);
const ctor = factory.createConstructorDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*parameters*/ [],
/*body*/ body,
);

const newBody = factory.createBlock([]);
const updatedCtor = factory.updateConstructorDeclaration(
ctor,
/*decorators*/ ctor.decorators,
/*modifiers*/ ctor.modifiers?.filter(isModifier),
/*parameters*/ ctor.parameters,
/*body*/ newBody,
);

assert.strictEqual(updatedCtor.body, newBody);
});
});
});
}