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

Unable to parse file: 'Unexpected token ...' #34

Open
ndr47 opened this issue Jun 28, 2021 · 2 comments
Open

Unable to parse file: 'Unexpected token ...' #34

ndr47 opened this issue Jun 28, 2021 · 2 comments

Comments

@ndr47
Copy link

ndr47 commented Jun 28, 2021

I am getting the following error:

Unable to parse file: /path/to/file 
Error: Error: Line XX: Unexpected token ...
...
description: 'Unexpected token ...'

My tsconfig.json:

{
	"compilerOptions": {
		"alwaysStrict": true,
		"allowJs": true,
		"baseUrl": ".",
		"declaration": true,
		"esModuleInterop": true,
		"experimentalDecorators": true,
		"lib": [
			"ESNext",
			"ESNext.AsyncIterable",
			"DOM"
		],
		"module": "commonjs",
		"moduleResolution": "node",
		"noFallthroughCasesInSwitch": true,
		"noImplicitThis": true,
		"noImplicitAny": true,
		"noUnusedLocals": true,
		"noUnusedParameters": true,
		"outDir": "./dist",
		"rootDir": "./",
		"paths": {
			"~/*": [
				"./*"
			],
			"@/*": [
				"./*"
			]
		},
		"sourceMap": true,
		"strict": true,
		"strictNullChecks": true,
		"strictFunctionTypes": true,
		"strictPropertyInitialization": true,
		"target": "ES2018",
	},
	"include": [
		"src/**/*"
	],
	"exclude": [
		"node_modules"
	]
}

My only .ts file in /src

// /src/index.ts
const myarr:string[] = [];

const a = {
	...myarr
}

Step to reproduce:

tsc -b
npx tspath -f
// Typescript version
Version 4.3.2

Why the pareser is not understanfing the syntax "..."? Is there any configuration I am missing?

@SrHenry
Copy link

SrHenry commented Aug 31, 2021

I'm getting into a similar problem, seems to happen while compiling to target above 'es6' when using some language features such as spread operator, null coalescing operator, and other stuff above es6, which seems that those stuff cannot be parsed by tspath

@dcsan
Copy link

dcsan commented Mar 20, 2022

I confirm i'm using these features, also Experiment Decorators, and have the same problem.

what alternatives are there? do i have to redo all the paths in my entire app to be relative paths?

i'm not really sure where to start with babel/webpack to fix this.

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

No branches or pull requests

3 participants