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

[Bug]: There's seemingly no way to get a template declaration's type parameters defaults as Type instances #5448

Open
4 tasks done
TomerAberbach opened this issue Dec 26, 2024 · 0 comments
Labels
bug Something isn't working needs-area

Comments

@TomerAberbach
Copy link
Contributor

Describe the bug

Given a TemplatedType that passes isTemplateDeclaration, there doesn't seem to be a way to get the defaults of its type parameters as Type instances.

This blocks some of what I want to implement in TomerAberbach/typespec-fast-check#76. I want to emit functions with default values for each templated type. e.g.

model TemplateModel<A, B = string> {
  a: A,
  b: B
}

Should become the following from my emitter:

import * as fc from "fast-check";

export const TemplateModel = (a, b = fc.string()) =>
  fc.record({
    a: a,
    b: b,
  });

But I can't figure out any way to get the Type for the = string default from the TypeSpec file.

Reproduction

See above.

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

No branches or pull requests

1 participant