feat: better context types through codegen#15145
feat: better context types through codegen#15145florian-lefebvre wants to merge 10 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: df22467 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
| 📦 Package | 🔒 Before | 🔓 After |
|---|---|---|
| @cloudflare/kv-asset-handler | trusted-with-provenance | none |
| @cloudflare/unenv-preset | trusted-with-provenance | none |
| workerd | trusted-with-provenance | none |
| undici | provenance | none |
| miniflare | trusted-with-provenance | none |
| youch | provenance | none |
| @cloudflare/workerd-darwin-64 | trusted-with-provenance | none |
| @cloudflare/workerd-darwin-arm64 | trusted-with-provenance | none |
| @cloudflare/workerd-linux-64 | trusted-with-provenance | none |
| @cloudflare/workerd-linux-arm64 | trusted-with-provenance | none |
| @cloudflare/workerd-windows-64 | trusted-with-provenance | none |
| wrangler | trusted-with-provenance | none |
| * @message | ||
| * The `security.csp` configuration isn't enabled. | ||
| */ | ||
| export const CspNotEnabled = { |
There was a problem hiding this comment.
@sarah11918 I'd like to remove this error in v6, it was only used while csp was in experimental. Is it fine?
There was a problem hiding this comment.
@florian-lefebvre Yes, assuming this message is about CSP being available to the user (and not whether or not csp is configured true) then makes perfect sense to remove since it will be available by default in v6!
(I know we have had discussions about whether to remove or deprecate error messages in the past, and I'm not sure where we landed on error messages used in experimental features that are not needed once the feature is stable. So to be clear, it seems like the message is OK to not have any more because it only relates to experimental, behind a flag, behaviour. Whether the solution is to remove or deprecate is a separate question. 😄 )
| * [Astro reference](https://docs.astro.build/en/reference/experimental-flags/csp/#cspinsertdirective) | ||
| */ | ||
| insertDirective: (directive: CspDirective) => void; | ||
| csp: ConditionalType< |
There was a problem hiding this comment.
@sarah11918 in this PR, context.csp may be undefined. What kind of changeset do I need? Asking given we're still in alpha so IDK if that deserves another major changeset
|
@Princesseuh by any chance, do you know how can I fix this TS issue? Doesn't seem to like references but I need them to properly test |
|
Would it work to just change the includes? It seems like you could just include the specific files you need |
|
You mean in the root tsconfig? |
|
No in |
|
I tried a few things but not including |
Todo
Changes
sync, generates better types forAPIContextandastro:config/serverbased on the Astro internals. For example, whether sessions are enabled or notcontext.cspcan now be undefined and will log a warning if accessed when not enabled, to matchsessionsi18nhas also been updated accordinglyTesting
Docs