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

Comments in tsconfig are not supported #45

Open
giyyapan opened this issue Jul 5, 2018 · 3 comments
Open

Comments in tsconfig are not supported #45

giyyapan opened this issue Jul 5, 2018 · 3 comments

Comments

@giyyapan
Copy link

giyyapan commented Jul 5, 2018

Hi all,

The default typescript loader works fine for me, but after I install parcel-plugin-typescript and restart parcel, this error appear. (and no type check result )

Server running at http://localhost:1234 
✨  Built in 665ms.
⚠️  Unexpected token }
    at unexpected (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:121:9)
    at expect (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:115:5)
    at parse_object (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:140:5)
    at walk (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:91:14)
    at parse_object (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:148:33)
    at walk (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:91:14)
    at Object.parse (/home/giyya/[path-to-project]/node_modules/json-parser/index.js:55:16)
    at Object.parse (/home/giyya/[path-to-project]/node_modules/comment-json/lib/parse.js:8:17)
    at Object.<anonymous> (/home/giyya/[path-to-project]/node_modules/parcel-plugin-typescript/build/backend/config-loader.js:25:37)
    at Generator.next (<anonymous>)

This is my tsconfig.json:

{
  "compilerOptions": {
    "sourceMap": true,
    "alwaysStrict": true,
    "noImplicitAny": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "strict": true,
    "strictNullChecks": false,
    "noFallthroughCasesInSwitch": true,
    "experimentalDecorators": true,
    "target": "es5",
    "module": "es2015",
    "baseUrl": "./ts",
    "outDir": "./js",
    "moduleResolution": "classic",
  },
  "parcelTsPluginOptions": {
    // If true type-checking is disabled
    "transpileOnly": false
  },
  "compileOnSave": false
}

Let me know if you need more information.

@fathyb fathyb changed the title "Unexpected token }" error after installing parcel-plugin-typescript Comments in tsconfig are not supported Jul 19, 2018
@raould
Copy link

raould commented Jul 26, 2018

hi,

  • I am also getting the "!! unexpected token }" error.
  • I did have a tsconfig.json of my own lying around from using tsc alone to look for type errors since parcel by default only transpiles.
  • my tsconfig.json did not have any comments in it, and was well formed, and tsc liked it.
  • but i got the above error.
  • once i deleted my local tsconfig.json then this plugin worked more as i expected, the particular error went away and i started to get actual typescript static checking reports.
  • problem is i guess i need to have a tsconfig.json around so i can use baseUrl?

versions:
node v8.11.3
windows 7 pro x64
my versions in package.json are:

    "devDependencies": {
        "@types/socket.io": "^1.4.0",
        "parcel": "^1.9.7",
        "parcel-plugin-typescript": "^1.0.0",
        "typescript": "^2.9.2"
    },
    "dependencies": {
        "phaser": "^3.11.0",
        "socket.io": "^1.4.0"
    }

my tsconfig.json, which might be horrible since i am new to typescript, and especially because i guess i have to try to base it off of parcel's hidden internal default? At any rate, when i do "tsc -p ." i do not get any errors fwiw.

{
	"compilerOptions": {
		"pretty": false,
        "module": "commonjs",
        "esModuleInterop": true,
		"jsx": "preserve",
        "baseUrl": "./src",
        "paths": {
            "src/*": ["./src/*"],
        },
		"noEmit": false,
		"noImplicitAny": true,
		"removeComments": true,
		"preserveConstEnums": true,
		"sourceMap": true,
        "strict": true,
	},
	"include": [
		"src/**/*.ts",
		"lib/types/phaser.comments.d.ts"
	],
    "exclude": [
        "node_modules"
    ],
}

@gabriofr
Copy link

gabriofr commented Aug 8, 2018

Had the same problem (without comments in the tsconfig.json), got rid of it by adding an empty "parelTsPluginOptions under compileroptions.

Like so: "parcelTsPluginOptions": {}

@gabriofr
Copy link

gabriofr commented Aug 8, 2018

On further inspection a trailing comma from inside the compilerOptions might be what caused this. Removed the line I mentioned above and a trailing comma and the "Unexpected token }" error is now gone.

@raould : try to change your config to this:

{
  "compilerOptions": {
    "pretty": false,
    "module": "commonjs",
    "esModuleInterop": true,
    "jsx": "preserve",
    "baseUrl": "./src",
    "paths": {
      "src/*": ["./src/*"]
    },
    "noEmit": false,
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true,
    "strict": true
  },
  "include": ["src/**/*.ts", "lib/types/phaser.comments.d.ts"],
  "exclude": ["node_modules"]
}

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

No branches or pull requests

4 participants