Open lednhatkhanh opened 5 years ago
Have you added the typescript extensions in your babel config? Here's my config for example, which works fine with @babel/preset-typescript
...
[
'babel-plugin-module-resolver',
{
cwd: 'packagejson',
root: ['./src'],
alias: {
lib: './src/lib'
},
extensions: ['.js', '.ts']
}
]
"settings": {
"import/resolver": {
"node": {
"paths": ["./src"],
},
"babel-module": {}
}
}
I did the other way around, by adding the extensions to te eslintrc config. I think that the example on the README needs to be improved to include some bits of configuration. Right now it only has an empty object and that is kinda useless. Also linking to this documentation will probably be better because it is too hard on the linked one to find useful bits of config.
Bumped into this as well, the secret ingredient is adding the extensions
option as mentioned above.
Babel itself doesn't complain when leaving out extensions
but this plugin for some reason does. (Assuming @babel/preset-typescript
handles this)
The most elegant option is in my opinion to thus add this to the ESLint configuration
// .eslintrc.yml
settings:
import/resolver:
babel-module:
extensions:
- ".js"
- ".ts"
// Add other extensions if needed
Sorry for unearthing a very old thread, but this was a life saver. Adding the extensions part fixed my unresolved import errors.
How can I config it to support typescript? The docs doesn't mention anything about this. Thanks.