A simple tsserver
and ts-patch
plugin that enables function decorators.
npm i function-decorator-ts-plugin -D
# or
yarn add function-decorator-ts-plugin -D
It is assumed that you will use ts-patch
instead of ttypescript
.
Just add this plugin to tsconfig.json
:
{
"compilerOptions": {
"plugins": [{
"name": "function-decorator-ts-plugin",
"transform": "function-decorator-ts-plugin/transformer",
"transformProgram": true
}]
}
}
If you use VSCode, you may need to switch the typescript version to local one by adding this setting in .vscode/settings.json
:
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
- Decorated functions are not hoisted
- There is no type cheсking in decorator expressions