3

The TypeScript compiler (tsc) emits valid JS even when it has type errors. I am in a situation where I need to compile a TypeScript project to JS but cannot install the required .d.ts files for it to correctly type check.

Is there a way I can get tsc to ignore any type errors, but still show other kinds of errors such as syntax errors?

Thanks

2 Answers 2

2

You can use babel 7 with @babel/plugin-transform-typescript to transpile typescript to JS. When you edit, you get the typescript autocomplete and everything. When you compile, types are just stripped away so any typerrors you might have don't matter.

Sign up to request clarification or add additional context in comments.

1 Comment

I haven't tested it, but it sounds like just what I was looking for. :)
1

Is there a way I can get tsc to ignore any type errors, but still show other kinds of errors such as syntax errors

No with TypeScript files. You can use the allowJS option to compile js files through typescript compiler and then it will only complain about syntax errors 🌹

2 Comments

Thanks @basarat. Looks like I'll have to work around my problem another way.
This answer is outdated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.