IncomingRequestCfPropertiesGeographicInformation makes geo property access an error (regression from 3.17.0)
See original GitHub issueIncomingRequestCfPropertiesGeographicInformation
(as part of the IncomingRequestCfProperties
union type) is defined in such a way that it treats accessing of geo fields on the Request
instances .cf
field as an error.
Here’s a Typescript Playground Link for an isolated case that demonstrates the issue.
This makes e.g. this code to raise a type error:
/* request is a Request instance */
console.log(request.cf?.city)
Error: Property 'city' does not exist on type 'IncomingRequestCfProperties<unknown>'.
Expectation: read access to any geo property shouldn’t be treated as a type error.
This is a regression from v3.17.0 where it worked fine, and is likely related to this change.
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:7 (4 by maintainers)
Top Results From Across the Web
cfproperty
Defines properties and their annotations for a ColdFusion component (CFC). The properties are used to create complex data types for web ...
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 FreeTop 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
Top GitHub Comments
While the type is technically valid, the change did break existing code in a minor version upgrade (without a breaking change in the actual Workers runtime). As such I’d support allowing optional chaining again and leaving any discussion of changing this to V4.
I guess this is question of whether it is reasonable to support optional chaining on the (possible) cf property or not? My pull request was ultimately because I do use optional chaining (rather than the property check method noted above). Seems that both are technically valid?