knightedcodemonkey / duel

TypeScript dual packages.
MIT License
20 stars 4 forks source link

does not support JSONC #32

Closed Zamiell closed 9 months ago

Zamiell commented 9 months ago

Hello, and thanks for the package.

I tried it out on my repo and got the following error:

$ npx duel
The config file found at D:\Repositories\foo\tsconfig.json is not parsable as JSON.

The error message implies that duel is parsing the "tsconfig.json" file using JSON. But that is a bug, because "tsconfig.json" files are not JSON files, they are JSONC files. JSONC is a format which allows both comments and trailing commas.

You are supposed to parse it with something like the following:

import JSONC from "jsonc-parser";

const json = JSONC.parse(fileContents);

I believe that this is how TypeScript itself parses it, as well as VSCode, and so on.

knightedcodemonkey commented 9 months ago

Thanks for the reminder that tsconfig.json is not really JSON.

Not strictly necessary, but if you could provide an example of your configuration that would be helpful.

Zamiell commented 9 months ago

Sure thing, the tsconfig.json that I was using is here: https://github.com/IsaacScript/isaacscript/blob/main/packages/isaacscript-common-ts/tsconfig.json

knightedcodemonkey commented 9 months ago

You want to give #33 a look over? Specifically, I did not add support for allowEmptyContent...

Zamiell commented 9 months ago

seems fine, thanks

knightedcodemonkey commented 9 months ago

Published to npm v1.0.4.