21

I have this:

$ tsc -m amd --outFile dist/out.js lib/index.ts

lib/index.ts(87,48): error TS1005: ';' expected.

Is there a command line option I can use to ignore errors?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • `tsc --help` doesn't provide any options to do this...what the heck – Alexander Mills Jan 11 '18 at 05:13
  • 6
    What do you mean ignore errors? That should still output the compiled JS. There is a switch `--noEmitOnError` which is set to false by default. If you were to set it to true it would not emit JS (+ .d.ts). – Pricey Jan 11 '18 at 05:15
  • Are you using TSLint? Check for tslint.json, as that looks to be where that error would be originating from. – Pricey Jan 11 '18 at 05:16
  • 4
    What is the context of the error you're trying to ignore? Is it a npm library or is it your own code? What version of TypeScript do you have (`tsc -v`)? This sounds like a fatal syntax error that is preventing the compiler from completing compilation; it can't just be ignored. – Greg Rozmarynowycz Jan 11 '18 at 05:42
  • @AlexanderMills I noticed you recently started a bounty. Can you answer Greg's question? – Matt McCutchen Oct 01 '18 at 01:45
  • any errors, ultimately i just want to make sure it compiles to full possibility. of course if the error is too severe it wont be able to compile. – Alexander Mills Oct 01 '18 at 03:09
  • 6
    @AlexanderMills You can ignore semantic errors (aka type erorrs, the kind of restrictions typescript imposes on top of JS) but you can't ignore syntactic errors (ie the syntax on JS/TS is invalid). The error you cite there is a sintactic error and will not be ignorable. If you don't specify other compiler options, the compiler will still emit JS even on semantic errors so taht should work out of the box. – Titian Cernicova-Dragomir Oct 01 '18 at 12:43
  • 2
    Why don't you fix the error? – k0pernikus Nov 12 '18 at 14:01
  • @TitianCernicova-Dragomir It doesn't have to be a syntactic error. If he is using a linter (as Pricey pointed out), it could enforce setting semicolons where it wouldn't be needed to compile to valid JavaScript. – Johannes Klauß Jan 17 '19 at 10:02
  • 1
    Can you give us the code so we can see why you have an error in the first place? – Binary Brain Mar 05 '19 at 17:52

4 Answers4

1

No. There is no option to disable error Reports in TypeScript.

I just recently tried that, to improve my build pipeline. I checked the the TypeScript sources. It shouldn't be too complicated to code a flag to basically ignore all errors. But I didn't want to go through the whole PR/Approval Process for something that does the opposite of what typescript does. I found a different solution.

I also have a huge, converted code-base. There are other tools that transform TypeScript to JavaScript (but they lack Error Checking - which is what you want):

  1. sucrase https://github.com/alangpierce/sucrase
  2. @babel/preset-typescript https://babeljs.io/docs/en/babel-preset-typescript

Both work great in combination with rollup.js and their according plugins.

htho
  • 1,549
  • 1
  • 12
  • 33
1

You can use // @ts-nocheck at the top of your files to have typescript not check them. This will still compile the code. To the point of @Jono on another question, yes, you will still have to go through every file to do this, although it is much less work than adding // @ts-ignore to every line. Source

codingtuba
  • 366
  • 2
  • 13
0

With the // @ts-ignore comment, Typescript compiler will ignore the line below it.

For example, you got an compiling error here:

enter image description here

enter image description here

Then just add // @ts-ignore enter image description here

Giang Nguyen
  • 450
  • 8
  • 17
  • 19
    In the example of changing an old project to typescript, you need a command line option so you don't have to add thousands of those comments... – Jono Feb 28 '20 at 23:19
0

You can use another command like: build: tsc -m amd --outFile dist/out.js lib/index.ts new-build: npm run build || exit 0;

|| exit 0; always return 0; that is success code;

André
  • 1,602
  • 2
  • 12
  • 26
oszerone
  • 1
  • 1