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

BBUI TS scaffolding + helpers conversion #15385

Merged
merged 5 commits into from
Jan 17, 2025
Merged

BBUI TS scaffolding + helpers conversion #15385

merged 5 commits into from
Jan 17, 2025

Conversation

aptkingston
Copy link
Member

Description

This PR adds the required config so that BBUI can properly build typescript code in both svelte components and .ts files.

I've converted the helpers and the Heading component to TS as an example of both.

I've also added a dev script so that bbui is continually built in dev, highlighting any build issues which may otherwise go unnoticed.

Copy link

qa-wolf bot commented Jan 17, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@aptkingston aptkingston marked this pull request as ready for review January 17, 2025 11:29
Copy link
Collaborator

@adrinr adrinr left a comment

Choose a reason for hiding this comment

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

Thanks for that!

export let noPadding = false
export let weight = "default" // light, heavy, default
export let size: "XS" | "S" | "M" | "L" = "M"
export let textAlign: string | undefined = undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that the | undefined is not required, as it gets inferred by the = undefined

Copy link
Member Author

Choose a reason for hiding this comment

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

You got me hopeful as I have done this in loads of places and would love to remove it!

But it does seem required. If I remove it:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I see. It's caused to adding the default tsconfig. The strictNullChecks is the culprit

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I think I understand the difference. In this case textAlign actually is optional, so I want to type is as possibly undefined. If i change strictNullChecks to false then it lets me set it as undefined, but it is typed as string only which is incorrect for this use case and potentially dangerous (unless all our code was TS, then it would be easy to spot any errors).

I'll keep this as-is, because I think it's more correct for this use case, in that it actually is optional 👍

@aptkingston aptkingston enabled auto-merge January 17, 2025 15:05
@aptkingston aptkingston merged commit a2c7729 into master Jan 17, 2025
20 checks passed
@aptkingston aptkingston deleted the bbui-ts branch January 17, 2025 15:15
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants