Categories
TypeScript Answers

How to fix the ‘Missing file extension “ts” import/extensions’ error with TypeScript and ESLint?

Spread the love

Sometimes, we want to fix the ‘Missing file extension "ts" import/extensions’ error with TypeScript and ESLint.

In this article, we’ll look at how to fix the ‘Missing file extension "ts" import/extensions’ error with TypeScript and ESLint.

How to fix the ‘Missing file extension "ts" import/extensions’ error with TypeScript and ESLint?

To fix the ‘Missing file extension "ts" import/extensions’ error with TypeScript and ESLint, we should add the ts extension into the import/extension property.

For instance, we write

{
  //...
  "rules": {
    "import/extensions": [
      "error",
      "ignorePackages",
      {
        "js": "never",
        "jsx": "never",
        "ts": "never",
        "tsx": "never"
      }
    ]
  }
  //...
}

to add ts into the import/extensions array in .eslintrc to clear the error.

Conclusion

To fix the ‘Missing file extension "ts" import/extensions’ error with TypeScript and ESLint, we should add the ts extension into the import/extension property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *