question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting a compilation error when compiling components with Tsnode

See original GitHub issue

Hello 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:

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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
FrancescoBorzicommented, Jun 30, 2020

confirmed, I got the same issue

1reaction
arturovtcommented, Jul 16, 2020

Btw I didn’t find any example tests in the integration/app folder of ngneat/until-destroy package.

There is an app.component.spec.ts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random errors during typescript compilation #185 - GitHub
Hello guys! I was using ts-node-dev@1.0.0-pre.54 with node v12.13.0 and random errors appeared at compilation time.
Read more >
Error: TSError: Unable to compile TypeScript - Stack Overflow
First I remove ts-node and typescript from package.json . then, ... Error: TSError: ⨯ Unable to compile TypeScript Cannot find type ...
Read more >
Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can provide insight in diagnosing and solving problems.
Read more >
Troubleshooting | ts-node - TypeStrong · GitHub
Type errors from the compiler are thrown as a TSError . These are the same as errors you get from tsc . SyntaxError...
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found