Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing error: '=' expected in `import type`

I am using create-react-app with TS and do import type but eslint complains in VS Code saying that Parsing error: '=' expected when hovering type in import type. I'm using eslint, 6.7.2

like image 591
JeromeDL30 Avatar asked Jan 21 '20 01:01

JeromeDL30


People also ask

What is parsererror - expected pragma?

I answered the question about Remix: ParserError: Expected pragma. import directive, or contract/library/interface definition which is caused by the abstract keyword with solidity 0.5.0. By removing it you have a new error with the virtual keyword which has been introduced too by Solidity 0.6.0.

How do I fix string literal expected error in typescript?

The TypeScript error "String literal expected" occurs when we have a syntax error, most often in an import statement. To solve the error, make sure to not use any variables when resolving your import paths and import as `import {myFunction} from './myFile'`.

What does error error parsing expected at the last 3 lines?

error Parsing error: ',' expected at the last 3 lines of the code. This is the correct error. Your code is invalid. This is why you should avoid long complex lines like that. Check the bracket matching on your last line. Sorry, something went wrong. @bradzacher yeah, agreed. This code is invalid.

What does error error parsing mean?

error Parsing error: ',' expected at the last 3 lines of the code. This is the correct error. Your code is invalid. This is why you should avoid long complex lines like that. Check the bracket matching on your last line.


Video Answer


2 Answers

UPDATE: The syntax is now supported by the latest versions of @typescript-eslint/parser and @typescript-eslint/eslint-plugin.


ESLint support for TS import type syntax is working in progress.

Issue: https://github.com/typescript-eslint/typescript-eslint/issues/1436

Pull request: https://github.com/typescript-eslint/typescript-eslint/pull/1465

like image 153
golopot Avatar answered Oct 11 '22 16:10

golopot


Prettier

If you're using prettier rather than ESLint then the solutions is:

npm update prettier@latest
# Or yarn
yarn upgrade prettier@latest

Which installed prettier version "2.6.2". Which worked for me with import type { } from './types' syntax

like image 3
Ali Fensome Avatar answered Oct 11 '22 16:10

Ali Fensome