tst-reflect
tst-reflect copied to clipboard
Support decorators from TS 4.8
Seems like I've got an issue with the transformer over a specific version. The tests run on a fork but it fails over the project using it, as the resulted node_modules/tst-reflect-transformer/dist/getDecorators.js.
if (!(declaration === null || declaration === void 0 ? void 0 : declaration.decorators)) {
return undefined;
}
This is the typescript version resolved: typescript@^4.0.0: version "4.8.2"
tst version is the latest fork, same for the transformer.
ttypescript@^1.5.13: version "1.5.13"
`@deprecated decorators has been removed from Node and merged with modifiers on the Node subtypes that support them. Use ts.canHaveDecorators() to test whether a Node can have decorators. Use ts.getDecorators() to get the decorators of a Node.
For example:
const decorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined; 'decorators' is deprecated.ts(6385) typescript.d.ts(7918, 12): The declaration was marked as deprecated here.`
:)
Package json:
Using latest fork
{ "name": "test", "version": "1.0.0", "description": "", "scripts": { "build": "ttsc ./src/index.ts" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "ttypescript": "^1.5.13", "typescript": "^4.0.0" }, "dependencies": { "tst-reflect": "file:/home/tst-reflect/runtime", "tst-reflect-transformer": "file:/home/tst-reflect/transformer" } }
code:
` import { getType, reflect } from "tst-reflect";
function fooBar(: any, __: any) { console.log(, 1); }
@reflect() class Test { @fooBar id: number; }
(async () => { console.log( getType<Test>() .getProperties() .map((x) => x.getDecorators()) ); })();
`
Note, it only happens with yarn, as it resolves typescript with a different version due to "typescript": "^4.0.0" in package.json
Implemented for the v1. Not in the current version.