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

fixed generated default values for typescript SDK #7224

Merged
merged 2 commits into from May 6, 2024

Conversation

0xbochi
Copy link
Contributor

@0xbochi 0xbochi commented Apr 30, 2024

No description provided.

@helderco
Copy link
Contributor

Thanks @0xbochi! Please regenerate the client by running ./hack/make sdk:typescript:generate.

@helderco helderco requested a review from TomChv April 30, 2024 14:51
@TomChv
Copy link
Member

TomChv commented Apr 30, 2024

We worked together on this fix reported 2 weeks ago!

I tested this manually and it fixed the issue 🚀

Repro

  • Create 2 modules (e.g., foo and target)
  • Add the following code:
// foo/index.ts

import { dag, Container, object, func } from "@dagger.io/dagger"

@object()
class foo {
  @func()
  containerEcho(stringArg: string = "Hello, world"): Container {
    return dag.container().from("alpine:latest").withExec(["echo", stringArg])
  }
}
// target/index.ts

import { dag, Container, Directory, object, func } from "@dagger.io/dagger"

@object()
class Target {
  @func()
  async coucou(): Promise<Container> {
    return dag.foo().containerEcho() // We no longer need the parameter, but we can set it in `{ stringArg }`, otherwise the default value is used.
  }
}
  • Use foo in module target.
  • The TS generator now generate arguments with default value as optional.

Thank you @0xbochi for the collaboration!

@0xbochi
Copy link
Contributor Author

0xbochi commented Apr 30, 2024

Thanks @0xbochi! Please regenerate the client by running ./hack/make sdk:typescript:generate.

Hello,

i launched the make and it seems there is nothing more to generate 😄

@jedevc jedevc requested a review from helderco May 1, 2024 12:23
Copy link
Contributor

@helderco helderco left a comment

Choose a reason for hiding this comment

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

Thanks again @0xbochi! This could use some test coverage, but will approve for now.

@@ -0,0 +1,6 @@
kind: Fixed
body: Fixed default values typescript generator
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
body: Fixed default values typescript generator
body: Fixed default values generation for TypeScript function arguments

@TomChv TomChv merged commit 0709846 into dagger:main May 6, 2024
44 checks passed
vikram-dagger pushed a commit to vikram-dagger/dagger that referenced this pull request May 8, 2024
Fixed generated default values for typescript SDK

Signed-off-by: Bochi <[email protected]>
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.

None yet

3 participants