[Bug]: Getting ReferenceError when using decorators
See original GitHub issueVersion
12.2.2
Steps to reproduce
- Clone my repo at https://github.com/philippesc/ng-jest-issue
- yarn install
- yarn test
- You should see the error come up
Expected behavior
I expect that no error comes up as the test should work properly.
Actual behavior
This is what comes up:
ReferenceError: app_state_model_1 is not defined
5 | export class AppSelectors {
6 | @Selector([AppState])
> 7 | static appName(state: AppStateModel): string {
| ^
8 | return state.name;
9 | }
10 | }
at Object.<anonymous> (src/app/store/app/app.selectors.ts:7:25)
at Object.<anonymous> (src/app/services/some-nice-service/some-nice-service.spec.ts:3:1)
Additional context
This error came up in the context of migration to Angular 14 but it seems to be related to this package.
Environment
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Max
Binaries:
Node: 16.13.1 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.3.0 - /usr/local/bin/npm
npmPackages:
jest: 28.1.1 => 28.1.1
Issue Analytics
- State:
- Created a year ago
- Reactions:11
- Comments:7
Top Results From Across the Web
[Bug]: type-only imports cause ReferenceError #1199 - GitHub
This bug is caused by the fact that, the Language Service is in a Jest worker doesn't have enough information to transform Angular...
Read more >Angular: 7.2.1 ES6 class ReferenceError : Cannot access 'X ...
In my case, it wasn't any circular dependency, it was a bug in an array that I export and use inside one of...
Read more >Incorrect unresolved reference error with list comprehensions ...
PY-18157 Unresolved reference in list comprehension inside a decorator keyword ... There is easier way to get this bug, I think it is...
Read more >swc cannot access before initialization - You.com | The search ...
The problem only exists when using decorators。 exports.default = _class1; ^ ReferenceError: Cannot access '_class1' before initialization at Object.
Read more >@babel/plugin-syntax-decorators | Yarn - Package Manager
@babel/plugin-syntax-decorators ... Allow parsing of decorators. babel-plugin ... :eyeglasses: [Spec Compliance]; :rocket: [New Feature]; :bug: [Bug Fix] ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For me jest-preset-angular 12.0.0 works but 12.2.0 runs into this issue with decorators.
Looks like this was discussed in #1199 as well.