Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Support typescript #99

Open
lednhatkhanh opened this issue Feb 12, 2019 · 4 comments
Open

Support typescript #99

lednhatkhanh opened this issue Feb 12, 2019 · 4 comments

Comments

@lednhatkhanh
Copy link

How can I config it to support typescript? The docs doesn't mention anything about this. Thanks.

@GeKorm
Copy link

GeKorm commented Apr 26, 2019

Have you added the typescript extensions in your babel config? Here's my config for example, which works fine with @babel/preset-typescript

babel
...
[   
  'babel-plugin-module-resolver',
  {
    cwd: 'packagejson',
    root: ['./src'],
    alias: {
      lib: './src/lib'
    },
    extensions: ['.js', '.ts']
  }
]
eslint
"settings": {
  "import/resolver": {
    "node": {
      "paths": ["./src"],
    },
    "babel-module": {}
  }
}

@danielo515
Copy link

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.

@Robin-Hoodie
Copy link

Robin-Hoodie commented Mar 10, 2022

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

@vamshiaruru-virgodesigns

Sorry for unearthing a very old thread, but this was a life saver. Adding the extensions part fixed my unresolved import errors.

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

No branches or pull requests

5 participants