GithubHelp home page GithubHelp logo

Comments (7)

CMCDragonkai avatar CMCDragonkai commented on July 16, 2024 5

Yea this doesn't work for me. The "types": ["@cloudflare/workers-types"] doesn't do anything to my vscode.

I've written alot of TS, and most TS projects use the @types convention? Why not use that so we can just install @types/cloudflare-workers-types into dev dependencies.

from workers-types.

threepointone avatar threepointone commented on July 16, 2024

This doesn't seem right. If I had to guess, I'd think you were using an older version of @cloudflare/workers-types. Could you share your package.json/tsconfig.json?

from workers-types.

motiejunas avatar motiejunas commented on July 16, 2024

Same for me with @cloudflare/[email protected] The native Request interface is picked up by VSCode.

tsconfig.json:

...
"types": ["@cloudflare/workers-types"]
...

from workers-types.

rahulgi avatar rahulgi commented on July 16, 2024

I was able to resolve this by making sure I excluded webworker from the tsconfig lib option as documented at the top of the README

from workers-types.

motiejunas avatar motiejunas commented on July 16, 2024

Resolved this by adding es2020 to lib in tsconfig.json.

...
"lib": ["es2020"]
...

from workers-types.

romeovs avatar romeovs commented on July 16, 2024

If I add

"lib": ["es2020"]

to tsconfig.json, I get the following error:

Cannot find name 'Request'.

Here's my full tsconfig.json:

{
  "compilerOptions": {
    "target": "es2020",
    "strict": true,
    "lib": ["es2020"],
    "rootDir": "src",
    "outDir": "dist",
    "moduleResolution": "node"
  },
  "include": ["src/**/*.ts"],
  "exclude": ["node_modules", "dist"],
  "types": ["@cloudflare/workers-types"]
}

from workers-types.

qwtel avatar qwtel commented on July 16, 2024

The problem could be related to a (dev) dependency pulling in lib.dom or lib.webworker types via comment. You can find them with

grep -r '<reference lib="dom" />' node_modules/
grep -r '<reference lib="webworker" />' node_modules/

from workers-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.