Skip to content

Conversation

@chouchouji
Copy link
Contributor

The type of value should be string, maybe we can add type assert to pass this type check.

image

@changeset-bot
Copy link

changeset-bot bot commented Sep 5, 2025

⚠️ No Changeset found

Latest commit: 87cf493

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 5, 2025

@example/basic@example/changesets

npm i https://pkg.pr.new/bombshell-dev/clack/@clack/core@389
npm i https://pkg.pr.new/bombshell-dev/clack/@clack/prompts@389

commit: 87cf493

@43081j
Copy link
Collaborator

43081j commented Sep 5, 2025

the value can be undefined because you can press <return> before typing anything

so it is possible that validate(undefined) gets called

we should be doing something like:

if (!value || !value.test(regex)) {
  // error
}

@chouchouji
Copy link
Contributor Author

chouchouji commented Sep 5, 2025

the value can be undefined because you can press <return> before typing anything

so it is possible that validate(undefined) gets called

we should be doing something like:

if (!value || !value.test(regex)) {
  // error
}

Thanks for your reply. The example has an initialValue value. I try to press it. It is not undefined. If I have some wrong steps, please tell me.

钉钉录屏_2025-09-05 173032

@43081j
Copy link
Collaborator

43081j commented Sep 5, 2025

it does have an initial value so it means in this particular case, it can't be undefined

but as far as typescript is concerned, it can still be undefined because you might not have set the initial value

the types are currently right even though you've managed to make runtime code that never sets it as undefined

@chouchouji chouchouji force-pushed the docs-text-validation-example branch from e5527f8 to 87cf493 Compare September 5, 2025 09:45
@chouchouji
Copy link
Contributor Author

it does have an initial value so it means in this particular case, it can't be undefined

but as far as typescript is concerned, it can still be undefined because you might not have set the initial value

the types are currently right even though you've managed to make runtime code that never sets it as undefined

I get it. Initially, I added a non-null check. But after testing, I am confused that it should be string type. Thanks for your reply again. 🌹

@43081j 43081j merged commit 9341346 into bombshell-dev:main Sep 5, 2025
7 checks passed
@chouchouji chouchouji deleted the docs-text-validation-example branch September 5, 2025 11:13
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.

2 participants