Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module 'eslint' #379

Closed
StefanoMagrassi opened this issue Jan 21, 2020 · 3 comments · Fixed by #380
Closed

Could not find a declaration file for module 'eslint' #379

StefanoMagrassi opened this issue Jan 21, 2020 · 3 comments · Fixed by #380

Comments

@StefanoMagrassi
Copy link

Current behavior

My Webpack config file is written in TS and type-checked on test/release.

With v4 of fork-ts-checker-webpack-plugin tsc started to complain about a not found declaration file for eslint

node_modules/fork-ts-checker-webpack-plugin/lib/issue/eslint/EsLintIssueFactory.d.ts:1:25 - error TS7016: Could not find a declaration file for module 'eslint'. '/MY_PROJECT_DIR/node_modules/eslint/lib/api.js' implicitly has an 'any' type.
  Try `npm install @types/eslint` if it exists or add a new declaration (.d.ts) file containing `declare module 'eslint';`

1 import * as eslint from 'eslint';
                          ~~~~~~~~

node_modules/fork-ts-checker-webpack-plugin/lib/issue/eslint/FileAwareEsLintMessage.d.ts:1:25 - error TS7016: Could not find a declaration file for module 'eslint'. '/MY_PROJECT_DIR/node_modules/eslint/lib/api.js' implicitly has an 'any' type.
  Try `npm install @types/eslint` if it exists or add a new declaration (.d.ts) file containing `declare module 'eslint';`

1 import * as eslint from 'eslint';

Expected behavior

type-checking should pass

Steps to reproduce the issue

tsconfig.json

{
  "compilerOptions": {
    "noEmit": true,
    "target": "es5",
    "module": "commonjs",
    "esModuleInterop": true,
    "lib": ["es6", "dom", "es2016.array.include"],
    "importHelpers": true,
    "sourceMap": true,
    "outDir": "./dist",
    "jsx": "preserve",
    "alwaysStrict": true,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true,
    "types": ["node", "jest", "jest-enzyme"],
    "typeRoots": ["./typings", "./node_modules/@types"],
    "baseUrl": ".",
    "paths": {
      "*": ["*", "typings/*"]
    }
  },
  "include": [
    "./src",
    "./scripts",
    "./config",
    "./webpack.config.ts",
    "./typings"
  ]
}

webpack.config.ts

import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';

export = {
  // ... various webpack configuration

 plugins: [
  new ForkTsCheckerWebpackPlugin()
 ]
}

and then run

npx tsc

Environment

  • fork-ts-checker-webpack-plugin: 4.0.1
  • typescript: 3.7.5
  • tslint
  • eslint: 6.8.0
  • webpack: 4.41.5
  • os: Ubuntu 18.04
@johnnyreilly
Copy link
Member

johnnyreilly commented Jan 21, 2020

Thanks for the report. @piotr-oles how do you want to proceed with this? I'd suggest we don't want to make @types/eslint a dependency.

I suspect this is a side effect of moving to use import * as eslint from 'eslint'; style imports rather than targeted ones that only import the types being used.

If so, this could probably be fixed by switching back to the import { TYPE } from 'eslint'; style imports

@piotr-oles
Copy link
Collaborator

Thanks @StefanoMagrassi , I'm working on the fix.

You are right @johnnyreilly , I will remove @types/eslint dependency to forbid using types from eslint. The PR will be soon 👍

@piotr-oles
Copy link
Collaborator

🎉 This issue has been resolved in version 4.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants