I use Eslint for my project, use:
@typescript-eslint/parser
1.4.2@typescript-eslint/eslint-plugin
1.4.2eslint-import-resolver-typescript
1.1.1airbnb-base
and plugin:@typescript-eslint/recommended
or you can check my .eslintrc
:
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"typescript": {}
}
},
"rules": {
"no-plusplus": "off",
"import/no-cycle": "warn",
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/explicit-member-accessibility": "off"
}
}
In file A.ts
I use: export type Id = string;
and import from B.ts
: import { Id } from '../A';
I tried to use:
import A from '../A';
and call A.Id but ide throw error:
A only refers to a type, but is being used as a namespace here
Two way has an error, one from eslint
, one from IDE (Vs Code, maybe Tshint)
Can you help me fix one of them?
Thank in advance!
I don't think that your error is related to the Eslint. From what I can see, it seems to be a basic Typescript error.
Your A.ts
does not contain a default export. In order to import the entire module from A.ts
you should use
import * as A from '../A';
See also the Typsescript documentation on import
statements