Repository navigation
docs: TS add type & enum keyword in examples - #8895
Conversation
type & enum keyword doc
type & enum keyword doctype & enum keyword in examples
| ``` | ||
|
|
||
| TypeScript has multiple ways to support complex data types. However, the Dagger TypeScript SDK only supports it through fields (decorated with `@func()`) inside classes because `type` and `interface` keywords do not allows decorators. | ||
| TypeScript has multiple ways to support complex data types. Use a `class` when you need methods and privacy, use `type` for plain data objects with only public fields. |
There was a problem hiding this comment.
@TomChv should the Python and Go sections also be updated?
There was a problem hiding this comment.
No, this is specific to TypeScript. For example, in Python you use a class for both, and in Go you also use the same struct for both, so no need to mention.
| @object() | ||
| class Organization { | ||
| @func() | ||
| /** |
There was a problem hiding this comment.
@TomChv should the Python and Go snippets also be updated?
There was a problem hiding this comment.
No, this change basically allows TypeScript to define simple objects in other ways that feel more natural to TypeScript developers that want to use them. So it's a "multiple ways of doing the same thing" kind of thing.
If a user wants to use a "simple object", then it can't have functions. It's just fields, and they're all exposed to the Dagger API. For this use case that's probably what the user wants, the problem is if they then want to add a function they'd have to change the type to a class, but I think that would be expected for a TypeScript user as it's not Dagger specific.
fd97fbc to
1b6e2e1
Compare
1b6e2e1 to
5d76e2e
Compare
Signed-off-by: Tom Chauveau <[email protected]>
5d76e2e to
02d2bf7
Compare
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Follow up for #8824 (must be merged before ; this PR's branch is based on that one)