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

gts clean fails with file-not-found for tsconfig.json if it has c-style comments #442

Closed
stari4ek opened this issue Feb 14, 2020 · 1 comment · Fixed by #571
Closed

gts clean fails with file-not-found for tsconfig.json if it has c-style comments #442

stari4ek opened this issue Feb 14, 2020 · 1 comment · Fixed by #571

Comments

@stari4ek
Copy link

gts fix works well:

astar@7u:~/dev/tvirl/develop/fb/functions$ gts fix

gts clean fails with Not Found for tsconfig.json which exists:

astar@7u:~/dev/tvirl/develop/fb/functions$ gts clean
Error: /home/astar/dev/tvirl/develop/fb/functions/tsconfig.json Not Found
    at getBase (/home/astar/dev/tvirl/develop/fb/functions/node_modules/gts/build/src/util.js:77:15)
    at async Object.clean (/home/astar/dev/tvirl/develop/fb/functions/node_modules/gts/build/src/clean.js:24:23)

astar@7u:~/dev/tvirl/develop/fb/functions$ cat /home/astar/dev/tvirl/develop/fb/functions/tsconfig.json 
{
  "extends": "./node_modules/gts/tsconfig-google.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "lib",
    // override from google's one
    "lib": ["es2017"],
    "resolveJsonModule": true,
    // allows proper default export (used with ts-interface-builder)
    "esModuleInterop": true,
    // TODO: suppressed temporary. we do not want to resolve it for play-billing right now
    "noImplicitAny": false
  },
  "compileOnSave": true,
  "include": [
    "src/**/*.ts",
    "test/**/*.ts"
  ]
}

astar@7u:~/dev/tvirl/develop/fb/functions$ ls -la ./node_modules/gts/tsconfig-google.json
-rw-r--r-- 1 astar astar 441 окт 26  1985 ./node_modules/gts/tsconfig-google.json

Removing "comments" from tsconfig.json solves the issue.

It would be nice if better error message (failed to parse) is produced or it accepts such non-standard syntax (the rest works well with it)

Q00 added a commit to Q00/api_server_boilerplate that referenced this issue Feb 21, 2020
@JustinBeckwith JustinBeckwith self-assigned this Sep 28, 2020
@pastelmind
Copy link

pastelmind commented Dec 29, 2020

I'm seeing a similar error when there are //-comments in tsconfig.json:

$ npm run clean

> display3@0.1.0 clean C:\Users\Phil\Documents\GitHub\display3
> gts clean

version: 12
SyntaxError: Error: C:\Users\Phil\Documents\GitHub\display3\tsconfig.json
Unexpected token / in JSON at position 114
    at JSON.parse (<anonymous>)
    at getBase (C:\Users\Phil\Documents\GitHub\display3\node_modules\gts\build\src\util.js:58:29)
    at async Object.clean (C:\Users\Phil\Documents\GitHub\display3\node_modules\gts\build\src\clean.js:25:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! display3@0.1.0 clean: `gts clean`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the display3@0.1.0 clean script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Phil\AppData\Roaming\npm-cache\_logs\2020-12-29T11_54_44_103Z-debug.log

pastelmind added a commit to Loathing-Associates-Scripting-Society/display3 that referenced this issue Jan 4, 2021
Note: gts currently does not support comments inside tsconfig.json.
This is why I am leaving a detailed description here. Ugh...

See issue: google/gts#442

- Enable esModuleInterop, since we will use CommonJS modules such as
  vhtml and mock-require
- Enable JSX options tailored for vhtml
- Configure lib so that we won't accidentally use APIs unsupported by
  Rhino (and we're unwilling to polyfill them)
- Set transpilation target to ES5, since Rhino doesn't support several
  ES2015 syntax (e.g. template strings)
- Configure directories transpiled

Note: Currently, these configs also apply to tests in spec/ and build
scripts in node-scripts/, even though they run inside Node.js and do not
need these limitations. We should add a separate tsconfig for these, and
possibly set up project references so that we can build all of them at
once.
@bcoe bcoe closed this as completed in #571 Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants