Fixes for decorators property deprecations (#50343)

* Change type of deprecated 'decorators' property

* fix 'Invalid Arguments' error for create/update constructor in factory

* Update deprecation comments

* Make 'decorators' optional and 'undefined'

* Rename '_decorators' to 'illegalDecorators'

* Update baselines
This commit is contained in:
Ron Buckton
2022-08-19 14:27:26 -04:00
committed by GitHub
parent ef88fbb8ab
commit 284837d66b
11 changed files with 301 additions and 440 deletions

View File

@@ -81,5 +81,40 @@ namespace ts {
checkRhs(SyntaxKind.QuestionQuestionEqualsToken, /*expectParens*/ false);
});
});
describe("deprecations", () => {
beforeEach(() => {
Debug.enableDeprecationWarnings = false;
});
afterEach(() => {
Debug.enableDeprecationWarnings = true;
});
// https://github.com/microsoft/TypeScript/issues/50259
it("deprecated createConstructorDeclaration overload does not throw", () => {
const body = factory.createBlock([]);
assert.doesNotThrow(() => factory.createConstructorDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*parameters*/ [],
body,
));
});
// https://github.com/microsoft/TypeScript/issues/50259
it("deprecated updateConstructorDeclaration overload does not throw", () => {
const body = factory.createBlock([]);
const ctor = factory.createConstructorDeclaration(/*modifiers*/ undefined, [], body);
assert.doesNotThrow(() => factory.updateConstructorDeclaration(
ctor,
ctor.decorators,
ctor.modifiers,
ctor.parameters,
ctor.body,
));
});
});
});
}