Title: Problematic `PolymorphicRequest` Type? · Issue #5768 · getsentry/sentry-javascript · GitHub
Open Graph Title: Problematic `PolymorphicRequest` Type? · Issue #5768 · getsentry/sentry-javascript
X Title: Problematic `PolymorphicRequest` Type? · Issue #5768 · getsentry/sentry-javascript
Description: Looking at #5744, the PolymorphicRequest type seems wrong or rather dangerous to me. IMO this type needs to be a union (|) instead of an intersection (&). sentry-javascript/packages/types/src/polymorphics.ts Lines 16 to 21 in 9862a32 exp...
Open Graph Description: Looking at #5744, the PolymorphicRequest type seems wrong or rather dangerous to me. IMO this type needs to be a union (|) instead of an intersection (&). sentry-javascript/packages/types/src/polym...
X Description: Looking at #5744, the PolymorphicRequest type seems wrong or rather dangerous to me. IMO this type needs to be a union (|) instead of an intersection (&). sentry-javascript/packages/types/src/p...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/5768
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Problematic `PolymorphicRequest` Type?","articleBody":"Looking at https://github.com/getsentry/sentry-javascript/pull/5744, the `PolymorphicRequest` type seems wrong or rather dangerous to me. IMO this type needs to be a union (`|`) instead of an intersection (`&`).\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/9862a32899a41a3af9a5cd87c0d4a09a1d689e25/packages/types/src/polymorphics.ts#L16-L21\r\n\r\nWhy?: With an intersection, we're creating a new type that none of the frameworks support. This might lead to us making wrong assumptions about what a request might look like. For example, let's say a `ExpressRequest` has a field `someField: string`, but none of the others have `someField`, TS will still allow us to access `someField`, even though none of the others have it. (Not the best example since all of the fields we define are optional - I know... but still valid)\r\n\r\nWhat would I do?: Replace this type with a union and remove the optional fields from the framework-specific `Request` types (unless they're actually optional). That way we can apply proper type-safe type narrowing in all the places where we accept a `PolymorphicRequest`.\r\n\r\nWe probably don't have any actual errors because of this, but in its current state, this is very error-prone.\r\n\r\nI am opening this in a separate issue so we can discuss this regardless of open PRs.","author":{"url":"https://github.com/lforst","@type":"Person","name":"lforst"},"datePublished":"2022-09-19T08:51:11Z","url":"https://github.com/getsentry/sentry-javascript/issues/5768"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eb4f3ed5-8fa8-51fb-19d0-d3a31c17a3ca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B368:125D11:18C789:2142D4:6B042FAE |
| html-safe-nonce | b16d6fc0a7e1f9f91f6891a8102bdcee215c9c2311de4d3042050cfa8d8f6d2a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzY4OjEyNUQxMToxOEM3ODk6MjE0MkQ0OjZCMDQyRkFFIiwidmlzaXRvcl9pZCI6IjQxMTg1MzMzMTgzMzU4MDMzMTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | df0e87453e5d2b7712749bcd77fa4b34ede69eb1d19ca39fdb8b155851c41eef |
| hovercard-subject-tag | issue:1377620820 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/5768/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56e67ae69e5e23b90c1f2e5ff74fc466403f0e023ad0f5fb198f3ada3cf854ef/getsentry/sentry-javascript/issues/5768 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56e67ae69e5e23b90c1f2e5ff74fc466403f0e023ad0f5fb198f3ada3cf854ef/getsentry/sentry-javascript/issues/5768 |
| og:image:alt | Looking at #5744, the PolymorphicRequest type seems wrong or rather dangerous to me. IMO this type needs to be a union (|) instead of an intersection (&). sentry-javascript/packages/types/src/polym... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lforst |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width