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

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.