Closed jbjhjm closed 1 year ago
thx for your report.
my understanding is babel 7 parser fully supports typescript syntax. We even migrated from typescript to babel parser in jest-editor-support. for whatever reasons. but decorators are experimental (even in typescript compiler). jest-editor-support would need to add the corresponding plugin to make decorators work. probably the plugin is missing.
since you already figured out the issue originates in jest-editor-support, we need to create the issue there to get it fixed: https://github.com/jest-community/jest-editor-support/issues
best regards Tristan
Thx for blazingly fast reply @firsttris !
Who knows if typescript decorators will ever be marked stable 🤷♂️ The babel documentation on decorators mentions only class and method level decorators: https://babeljs.io/docs/en/babel-plugin-proposal-decorators And there is a 3rd party babel 7 plugin stating to add parameter-level decorators: https://github.com/WarnerHooh/babel-plugin-parameter-decorator Combining those two infos I'm kinda sure there's no official support for param decorators in Babel 7.
jest-editor-support documentation seems pretty sparse so I cannot see if there is any way to load the plugin without changing the library source code. I'll open a issue over on their repo.
i think its just a matter of adding the plugin here. https://github.com/jest-community/jest-editor-support/blob/master/src/parsers/helper.ts#L11
i refactored this from typerscript to bable_parser at some point
and of course, they need to release a new version, we need to increase the dependency version...
As soon as a test file contains a param decorator like e.g.
jest-runner will fail. There already was a issue report some time ago: https://github.com/firsttris/vscode-jest-runner/issues/225
Unfortunately the issue remains. Console reported the following error:
In the log paths one can see babel parser is generating this error. It seems some of the used dependencies try to transpile typescript based on babel.
I think this is whats happening:
So if jest-editor-support is not going to implement full typescript / tsc support, typescript files should be compiled to ECMAscript before being passed to the babel-based transpiler.