Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose decorator options #316

Merged
merged 4 commits into from
Apr 14, 2024

Conversation

nyannyacha
Copy link
Collaborator

@nyannyacha nyannyacha commented Apr 11, 2024

What kind of change does this PR introduce?

Feature

Description

List of arguments to be created due to the introduction of this PR

  • --decorator flag in subcommand start specifies the type of decorator to use on the main worker and event worker. If not specified, the decorator feature is disabled. (possible inputs: tc39, typescript, typescript_with_metadata)
  • --decorator flag in subcommand bundle specifies the type of decorator to use when bundling. If not specified, the decorator feature is disabled. (possible inputs are same above)

Apart from the CLI arguments above, when you create a User Worker via the API in the main service, you can specify the type of decorator to use on the User Worker.

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DecoratorType {
    /// Use TC39 Decorators Proposal - https://github.com/tc39/proposal-decorators
    Tc39,
    /// Use TypeScript experimental decorators.
    Typescript,
    /// Use TypeScript experimental decorators. It also emits metadata.
    TypescriptWithMetadata,
}
...

// type DecoratorType = "tc39" | "typescript" | "typescript_with_metadata"
const decoratorType = "typescript_with_metadata";

return await EdgeRuntime.userWorkers.create({
	...
	decoratorType
});
type experimentalDecorators emitDecoratorMetadata
tc39 - -
typescript
typescript_with_metadata

There are differences between Typescript's implementation of the decorator specification and the decorator specification specified by Ecma TC39, see the link below for a description of the differences:
tc39/proposal-decorators#329

Note that the typescript_with_metadata option allows concrete types in design time to be output with metadata during the transpiling process. This option is equivalent to emitDecoratorMetadata of tsconfig.json.
For more information on this topic, see the link below:
https://www.typescriptlang.org/tsconfig#emitDecoratorMetadata

Resolves #296

@nyannyacha nyannyacha marked this pull request as ready for review April 11, 2024 23:28
@laktek
Copy link
Contributor

laktek commented Apr 12, 2024

We would need to also update Supabase CLI for this to work on deployed edge-functions.

@nyannyacha nyannyacha merged commit 892ce19 into supabase:main Apr 14, 2024
3 checks passed
@nyannyacha nyannyacha deleted the feat-expose-decorator-opt branch April 14, 2024 21:09
Copy link

🎉 This PR is included in version 1.43.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Neither old (experimental) decorators nor new (stage 3) decorators work since upgrading to Deno 1.40
2 participants