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.

Errors that you would expect to get by running the typescript compiler are not being reported by the transformer

See original GitHub issue

Basically, if you write something like this in typescript:

    switch (x) {
      case 1:
      console.log('y');
      case 2:
      console.log(x);
    }

And put: "noFallthroughCasesInSwitch": true,

in your tsconfig.json, then if you compile w/ typescript (e.g. tsc) you’ll get an error. Thats good!

BUT, with the transformer, the typescript is transpiled successfully, and you don’t get an error.

There seems to be a whole slew of little nice errors you get normally with the typescript compiler, that the transformer isn’t reporting.

I believe its probably because the transpileModule function you are using does not do the full analysis that the normal complication pass does.

This seems relevant: https://github.com/Microsoft/TypeScript/issues/4864

Do you have any idea how we could fix this?

Thanks! Aaron

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ds300commented, Jun 17, 2017

That is the desired behaviour. i.e. the transformer should only report syntax errors which prevent emitting code. All other errors should be displayed/reported by external tooling like code highlighting and a precommit hook that runs tsc --noEmit.

Otherwise you couldn’t run type-unsafe code a dev time. Which might sound like an insane desire to some people, “why would you ever want to run unsafe code”, but is actually a very productive feature because it lets you experiment and make incremental changes with less overhead.

1reaction
aarondailcommented, Jun 22, 2017

Thanks for your response. I have been thinking about this for a few days… I admit it does feel a little foreign to me, but what you are saying is reasonable and I think I am coming over to your point of view. 😃

We are also going to be running tslint anyways, and if I think of these sorts of errors more like linting errors, then it feels very natural to not prevent emitting code on those errors.

So, yeah, in summary, I think I agree with you, and thank you for working on this project 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

transpileModule() does not generate diagnostics #4864 - GitHub
Errors that you would expect to get by running the typescript compiler are not being reported by the transformer ...
Read more >
Error: TSError: Unable to compile TypeScript - Stack Overflow
I updated my typescript version from 2.0.3 to 2.7.2 and then I was getting similar issues like below while running ng e2e ....
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 >
Typescript does not resolve modules through tsconfig.json's ...
I get an error: TS2307: Cannot find module 'services/authentication/index'. Even though simply compiling the Typescript through the CLI ...
Read more >
TypeScript Compiling with Visual Studio Code
Compiling TypeScript. TypeScript is a typed superset of JavaScript that transpiles to plain JavaScript. It offers classes, modules, and interfaces to help ...
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