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

[Typescript] DOM libs are undefined (v3.1.2) #104

Closed
wiesson opened this issue Mar 31, 2021 · 9 comments
Closed

[Typescript] DOM libs are undefined (v3.1.2) #104

wiesson opened this issue Mar 31, 2021 · 9 comments

Comments

@wiesson
Copy link

wiesson commented Mar 31, 2021

When installing cross-fetch v3.1.3, it somehow overrides the typescript settings. Despite having dom in lib in the tsconfig, Typescript starts to complain about e.g. window and URLSearchParams. If I downgrade to v3.1.2, it does not happen. Maybe you have an idea, why cross-fetch somehow overrides "everything" (?)

I'm using it with nextjs (latest version)

@wiesson wiesson changed the title [Typescript] DOM libs are undefined [Typescript] DOM libs are undefined (v3.1.2) Mar 31, 2021
@pbeyeler
Copy link

We're having the exact same problem. Would be great if this could be solved as soon as possible.

@lquixada
Copy link
Owner

@wiesson can you share your tsconfig?

@wiesson
Copy link
Author

wiesson commented Mar 31, 2021

Sure!

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "baseUrl": "src",
    "paths": {
      "@/components/*": ["components/*"],
      "@/lib/*": ["lib/*"],
      "@/utils/*": ["utils/*"],
      "@/types/*": ["types/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}

it is more or less the default tsconfig of Nextjs

@eps1lon
Copy link

eps1lon commented Apr 1, 2021

Possibly caused by f3b2fc4 which added no-default-lib triple slash directives. Once I remove that directive from my local typings, everything is back to normal. The directive will instruct TypeScript to not include their lib.d.ts.

I've never seen this directive used in library typings so I can't say what this commit tried to solve. Maybe @lquixada has some insight?

@Vadorequest
Copy link

Vadorequest commented Apr 1, 2021

This is breaking the faunadb library as well.

At this point, my whole project is unusable, is there a workaround (like a smart edit of the yarn.lock to force using the previous version?)

fauna/faunadb-js#459

And I can concur about the triple slash directive, it's what causing the issue.

@lquixada
Copy link
Owner

lquixada commented Apr 1, 2021

hey all! sorry for the trouble! adding local types to cross-fetch has been trickier than originally thought so I'm reverting those changes so everyone can run it safely. Please let me know if 3.1.4-alpha.0 works for you.

@Vadorequest
Copy link

For anyone affected by this, you can add the following to package.json:

  "resolutions": {
    "cross-fetch": "3.1.4-alpha.0"
  }

@Vinnl
Copy link

Vinnl commented Apr 1, 2021

@lquixada I can confirm that it fixes it for my project!

@lquixada
Copy link
Owner

lquixada commented Apr 2, 2021

just released 3.1.4

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

6 participants