Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred: SyntaxError: Expected double-quoted property name in JSON at position 908 #24

Closed
neverlose-lv opened this issue Oct 2, 2023 · 2 comments · Fixed by #30

Comments

@neverlose-lv
Copy link

neverlose-lv commented Oct 2, 2023

After updating to version 8.2.3 I receive an error, when try to extract the translations.
There is no such error when I use version 8.2.2

An error occurred: SyntaxError: Expected double-quoted property name in JSON at position 908
@michaelbromley
Copy link
Member

Hi, thanks for the report. Is there any stack trace with this error?

@sod
Copy link

sod commented Oct 6, 2023

It's the tsconfig dependency. The loadSync method call in the end, if it finds a tsconfig.json, will do JSON.parse on its contents:

CleanShot 2023-10-06 at 13 32 27@2x

But typescript doesn't use a pure JSON. they use their own parser, thats kinda json5'ish. It e.g. allows comments and dangling commas.

There is an issue for it TypeStrong/tsconfig#30, but as the last change for that library was 5 years ago, I doubt someone will touch it.

What this lib is concerned, the easiest fix may be, to replace loadSync usage with resolveSync (from npm:tsconfig) => fs.readFileSync (from node:fs) => json5.parse (from npm:json5).

Well, or you go through your tsconfigs and remove dangling commas/make them valid JSON :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants