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]: isTemplateDeclaration and isTemplateDeclarationOrInstance take TemplatedType instead of just Type #5447

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

TomerAberbach commented Dec 26, 2024

Describe the bug

isTemplateDeclaration and isTemplateDeclarationOrInstance take TemplatedType instead of just Type. This makes them a lot less useful and inconsistent with isTemplateInstance, which takes just a Type.

Presumably they were meant to take Type because they each have a type assertion of is TemplatedType, which is redundant with the parameter already being TemplatedType.

I ended up having to write this in my code (and checked that first) so that I could pass a type to isTemplateDeclaration:

const isTemplatedType = (type: Type): type is TemplatedType => {
  switch (type.kind) {
    case `Scalar`:
    case `Union`:
    case `Model`:
    case `Interface`:
    case `Operation`:
      return true
    default:
      return false
  }
}

Reproduction

See above

Checklist

@TomerAberbach TomerAberbach added the bug Something isn't working label Dec 26, 2024
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