Skip to content

docs: TS add type & enum keyword in examples - #8895

Merged
TomChv merged 2 commits into
dagger:mainfrom
TomChv:docs/ts-sdk-resolution-by-reference-follow-up
Nov 19, 2024
Merged

TomChv merged 2 commits into
dagger:mainfrom
TomChv:docs/ts-sdk-resolution-by-reference-follow-up

Conversation

@TomChv

@TomChv TomChv commented Nov 8, 2024

Copy link
Copy Markdown
Member

Follow up for #8824 (must be merged before ; this PR's branch is based on that one)

@TomChv
TomChv requested review from a team as code owners November 8, 2024 14:48
@TomChv TomChv self-assigned this Nov 8, 2024
@TomChv TomChv changed the title feat: typescript SDK resolve value by reference. docs: TS add type & enum keyword doc Nov 8, 2024
@TomChv TomChv changed the title docs: TS add type & enum keyword doc docs: TS add type & enum keyword in examples Nov 8, 2024
```

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomChv should the Python and Go sections also be updated?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomChv should the Python and Go snippets also be updated?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@TomChv
TomChv force-pushed the docs/ts-sdk-resolution-by-reference-follow-up branch from fd97fbc to 1b6e2e1 Compare November 13, 2024 16:59
@TomChv
TomChv force-pushed the docs/ts-sdk-resolution-by-reference-follow-up branch from 1b6e2e1 to 5d76e2e Compare November 19, 2024 14:59
@TomChv
TomChv force-pushed the docs/ts-sdk-resolution-by-reference-follow-up branch from 5d76e2e to 02d2bf7 Compare November 19, 2024 15:17
Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv merged commit f251869 into dagger:main Nov 19, 2024
TomChv added a commit to TomChv/dagger that referenced this pull request Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants