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

Export BaseField and its children to allow TypeScript type guard usage #482

Open
reda-alaoui opened this issue Nov 13, 2023 · 0 comments · May be fixed by #483
Open

Export BaseField and its children to allow TypeScript type guard usage #482

reda-alaoui opened this issue Nov 13, 2023 · 0 comments · May be fixed by #483

Comments

@reda-alaoui
Copy link
Contributor

reda-alaoui commented Nov 13, 2023

It looks like it is currently impossible to use TypeScript type guard on fields like this:

const defaultValue: string | undefined = action.fields
        .filter((field): field is TextField => field.type === 'text')
        .find(field => field.name === 'my-field-name' && field.type === 'text')?.value
// TS2322: Type
// string | number | boolean | Date | null | undefined
// is not assignable to type  string | undefined 

Could BaseField and its children be exported to allow this?

@reda-alaoui reda-alaoui linked a pull request Nov 13, 2023 that will close this issue
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 a pull request may close this issue.

1 participant