juanjoDiaz / streamparser-json

Streaming JSON parser in Javascript for Node.js and the browser
MIT License
138 stars 11 forks source link

The project doesn't compile if noFallthroughCasesInSwitch flag is set #26

Closed ZixZux closed 1 year ago

ZixZux commented 1 year ago

The project with this package included doesn't compile if 'noFallthroughCasesInSwitch' flag is set to 'true' in tsconfig.json.

juanjoDiaz commented 1 year ago

Hi @ZixZux ,

Typescript recommends using skipLibCheck to avoid this kind of issue.

I will fix it in the next release in any case.

ZixZux commented 1 year ago

Hi,

The flag skipLibCheck doesn't help in this case, because it only seems to work only for d.ts files: "Skip type checking of declaration files. [...] Rather than doing a full check of all d.ts files, TypeScript will type check the code you specifically refer to in your app’s source code."

But the errors are in your source typescript-files.

In common, source typescript-files shouldn't being included in the distributed package.

RobRendell commented 1 year ago

I have the same issue, failing to build because of my more strict compilerOptions - noFallthroughCasesInSwitch and noUncheckedIndexedAccess in my case.

The suggested solution is that "the package owner [should] release JavaScript and declaration files, not TypeScript files." What's interesting is that you do release JS and .d.ts files, and as far as I can see, correctly reference them in your package.json - you just also happen to bundle the src folder as well. So I don't know why Typescript is even inspecting your package's source when it should just be using the type declaration files. I added a comment to the issue I linked to, pointing out this apparent inconsistency.

Anyway, if you're going to omit the typescript files in the next release, that would prevent this particular issue. Looking forward to it!

juanjoDiaz commented 1 year ago

This took long enough...

Fixed in v0.0.14