Property 'cf' does not exist on type 'Request'
See original GitHub issueI tried adding this library to an existing Creact-React-App application.
I’ve added a hello world function, and I wrote this:
export const onRequest: PagesFunction = async (context) => {
// Contents of context object
const {
request, // same as existing Worker API
env, // same as existing Worker API
params, // if filename includes [id] or [[path]]
waitUntil, // same as ctx.waitUntil in existing Worker API
next, // used for middleware or to fetch assets
data, // arbitrary space for passing data between middlewares
} = context;
return new Response(
JSON.stringify({
country: request.cf.country,
continent: request.cf.continent,
})
);
};
However I am getting error:
Property 'cf' does not exist on type 'Request'.ts(2339)
With //@ts-ignore
it works just fine though.
What am I missing here?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Typescript Error: Property 'user' does not exist on type 'Request'
Be advised that "user" is not a property that is available natively in the Request object of Express. Make sure that you are...
Read more >property 'extend' does not exist on type 'typeof - You.com
I'm trying to add a menu bar to videoJS control bar in TypeScript but I'm getting an error saying "Property 'extend' does not...
Read more >Unable to compile TypeScript. Property 'user' does not exist on ...
Hello, I getting annoyed about typescript in my node api. I have written a jwtverify.ts. At first typescript has not accepted the req.user....
Read more >Request · Cloudflare Workers docs
Cloudflare-specific properties that can be set on the Request that ... The request.cf object is not available in the Cloudflare Workers ...
Read more >How to extend the Express Request object in TypeScript
Let's learn how to extend the Request type in TypeScript to make its ... Property 'user' does not exist on type 'Request<ParamsDictionary, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.The problem could be related to a (dev) dependency pulling in lib.dom or lib.webworker types via comment. You can find them with