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

preact@10.15.0 newly doesn't compile with TypeScript exactOptionalPropertyTypes #4024

Closed
ashvinsrivatsa opened this issue May 23, 2023 · 0 comments · Fixed by #4025
Closed

Comments

@ashvinsrivatsa
Copy link

Describe the bug

preact@10.14.1 compiles when TypeScript's exactOptionalPropertyTypes tsconfig setting is enabled. preact@10.15.0 doesn't:

node_modules/preact/compat/src/index.d.ts:140:19 - error TS2430: Interface 'ForwardRefExoticComponent<P>' incorrectly extends interface 'FunctionComponent<P>'.
  Types of property 'defaultProps' are incompatible.
    Type 'Partial<P> | undefined' is not assignable to type 'Partial<P>'.
      Type 'undefined' is not assignable to type 'Partial<P>'.

140  export interface ForwardRefExoticComponent<P>
                      ~~~~~~~~~~~~~~~~~~~~~~~~~

It's complaining that FunctionComponent<P> in src/index.d.ts has defaultProps?: Partial<P> but ForwardRefExoticComponent<P> in compat/src/index.d.ts (added at b55567f) has defaultProps?: Partial<P> | undefined instead of defaultProps?: Partial<P>.

To Reproduce

npm init --yes
npm install preact@10.15.0 typescript@5.0.4
echo "import 'preact/compat'" > index.ts
npx tsc index.ts --strictNullChecks --exactOptionalPropertyTypes

Expected behavior

Ideally, preact would continue to compile with this TypeScript configuration.

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