Getting a compilation error when compiling components with Tsnode
See original GitHub issueHello everybody,
I have a tricky problem.
I have the Angular CLI v9 + Angular v9 running concurrently with a node express server transpiled with tsnode that serves our REST backend mocks as JSON.
The problem is that this node mock server transpiles typescript files that import some interfaces and components that exist in our angular app, and although it doesn’t use the Angular components themselves (only the interfaces), it still transpiles them.
So when it tries to transpile components with the @UntilDestroy decorator, it gives and error (because Ivy isnt compiled yet - and in this case doesn’t need to be):
/node_modules/@ngneat/until-destroy/bundles/ng:/@ngneat/until-destroy/lib/until-destroy.ts:79
Object.defineProperty(type, defName, {
^
TypeError: Cannot read property 'get' of undefined
at decorateDirectiveJIT (/Users/3868648/Projects/sail-frontend/node_modules/@ngneat/until-destroy/bundles/ng:/@ngneat/until-destroy/lib/until-destroy.ts:79:40)
at decorateDirective (/Users/3868648/Projects/sail-frontend/node_modules/@ngneat/until-destroy/bundles/ng:/@ngneat/until-destroy/lib/until-destroy.ts:104:4)
at /Users/3868648/Projects/sail-frontend/node_modules/@ngneat/until-destroy/bundles/ng:/@ngneat/until-destroy/lib/until-destroy.ts:117:6
at DecorateConstructor (/Users/3868648/Projects/sail-frontend/node_modules/reflect-metadata/Reflect.js:541:33)
at Object.decorate (/Users/3868648/Projects/sail-frontend/node_modules/reflect-metadata/Reflect.js:130:24)
at Object.__decorate (/Users/3868648/Projects/sail-frontend/node_modules/tslib/tslib.js:96:96)
I was able to easily fix this by adding a check for the variable being used on line 76 of this file:
...
const property = Object.getOwnPropertyDescriptor(type, defName);
if (!property) {
return;
}
var getter = property.get;
...
How to reproduce:
- Go to the Repo that reproduces the bug and clone it
- Run
npm install
- Run
npm run mockserver
you will see the error.
Do you think it makes sense? I can create a PR for this.
If you have any comments/suggestions please let me know.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:10 (1 by maintainers)
confirmed, I got the same issue
There is an
app.component.spec.ts
.