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

fix(ts): type narrowing in forOfAttrTag function #336

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

LuLaValva
Copy link
Member

Previously, type expansion broke this type:

<my-tag>
  <@foo size="small"/>
  <@foo size="large"/>
</my-tag>

// my-tag.marko
export interface Input {
  foo: Marko.AttrTag<{
    size: "small" | "large"
  }>;
}

because instead of "small" | "large", the type lost its specificity and propagated as string.

This const prevents working code from throwing type errors, but it doesn't fix the long-winded error that it shown in addition to the very precise error when an invalid type is included (see snapshot examples). We should look into a way to filter out the big error when we know the small and direct one will exist.

Copy link

changeset-bot bot commented Jan 10, 2025

🦋 Changeset detected

Latest commit: bb612d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@marko/language-server Patch
@marko/language-tools Patch
@marko/type-check Patch
marko-vscode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@LuLaValva LuLaValva merged commit a4954b6 into main Jan 10, 2025
4 checks passed
@LuLaValva LuLaValva deleted the attr-tag-for-narrowing branch January 10, 2025 22:10
@github-actions github-actions bot mentioned this pull request Jan 10, 2025
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.

1 participant