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

Auto fix of unicorn/prefer-node-protocol rule breaks Typescript #552

Closed
leosuncin opened this issue May 26, 2021 · 5 comments
Closed

Auto fix of unicorn/prefer-node-protocol rule breaks Typescript #552

leosuncin opened this issue May 26, 2021 · 5 comments

Comments

@leosuncin
Copy link

Change from

import http from 'http';

To

import http from 'node:http';

Cause to Typescript fails to detect declarations

error TS2307: Cannot find module 'node:http' or its corresponding type declarations.

I'm using Typescript v4.2.4 and @types/node v15.6.1, also I'm using Next.js v10.2.3 so my tsconfig.json needs to be

{
  "compilerOptions": {
    "allowJs": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "lib": ["dom", "es2017"],
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": true,
    "noFallthroughCasesInSwitch": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "esnext"
  },
  "exclude": ["node_modules"],
  "include": ["**/*.ts", "**/*.tsx"]
}
@leosuncin
Copy link
Author

So, maybe this rule should be disabled for typescript files until those issues are fixed

@karlhorky
Copy link

@types/node@16.0.0 has been merged now - this now works again:

@karlhorky
Copy link

@leosuncin can you confirm this works for you? Then I think this issue can be closed.

@leosuncin
Copy link
Author

Works with @types/node v16

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

No branches or pull requests

3 participants