question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IncomingRequestCfPropertiesGeographicInformation makes geo property access an error (regression from 3.17.0)

See original GitHub issue

IncomingRequestCfPropertiesGeographicInformation (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:open
  • Created a year ago
  • Reactions:7
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Qantas94Heavycommented, Nov 9, 2022

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.

3reactions
philipatkinsoncommented, Nov 7, 2022

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found