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

Wrong TypeScript-types for InputText component #1674

Closed
Christoph-Wagner opened this issue Oct 15, 2021 · 1 comment
Closed

Wrong TypeScript-types for InputText component #1674

Christoph-Wagner opened this issue Oct 15, 2021 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Christoph-Wagner
Copy link
Contributor

Christoph-Wagner commented Oct 15, 2021

This is a pure typing issue, so the normal bug-template does not make a lot of sense.

File: https://github.com/primefaces/primevue/blob/master/src/components/inputtext/InputText.d.ts

Current

interface InputTextProps {
    modelValue?: string;
}

declare class InputText {
    $props: InputTextProps;
    $emit(eventName: 'update:modelValue', value: string): this;
}

Expected

interface InputTextProps {
    modelValue: string | null;
}

declare class InputText {
    $props: InputTextProps;
    $emit(eventName: 'update:modelValue', value: string | null): this;
}

modelValue?: string is the same as modelValue: string | undefined, per the documentation the default is null, and the .vue file also has props: { modelValue: null },. So undefined can never happen, but null is the default. Typecheckers will correctly complain if I use a potential null value as v-model: vue-tsc output: error TS2322: Type 'string | null' is not assignable to type 'string | undefined'.

This is current in master as of commit 4d1891b

@cagataycivici cagataycivici self-assigned this Oct 25, 2021
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Oct 25, 2021
@cagataycivici cagataycivici added this to the 3.8.2 milestone Oct 25, 2021
@Christoph-Wagner
Copy link
Contributor Author

That commit still has modelValue?: string; which does not allow null in the props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants