v27.0.0 breaks TypeScript typings
See original GitHub issueDescribe the bug
- some components (Button*/Dialog/TextInput/FilterList/…) have incorrect type definitions, and ts keeps complaining:
Property 'css' is missing in type '{}' but required in type 'Pick<TextInputInternalProps, "form" | "p" | "slot" | "style" | "title" | "pattern" | "children" | "type" | "theme" | "key" | "defaultChecked" | "defaultValue" | ... 317 more ... | "icon">'.ts(2741)
- callbacks like
onChange
/onKeyPress
inTextInput
are not giving us the right types, it will cause an error like:
Parameter 'e' implicitly has an 'any' type.ts(7006)
vscode shows the onChange
’s type definition is:
onChange?: (((event: React.FormEvent<HTMLSpanElement>) => void) & ((event: React.ChangeEvent<HTMLInputElement>) => void)) | undefined
which is not accurate
To Reproduce codesanbox
Expected behavior no error
Screenshots
Additional context v26 was fine
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:13 (6 by maintainers)
Top Results From Across the Web
v27.0.0 breaks TypeScript typings · Issue #1163 · primer/react
Describe the bug some components (Button*/Dialog/TextInput/FilterList/...) have incorrect type definitions, and ts keeps complaining: ...
Read more >27.0.0 - AG Grid
Breaking Changes. Version: ... 8th Feb 2022 - Grid v27.0.0 (Charts v5.0.0) ... AG-6004 - Typescript Examples in Example Runner; AG-6322 - Angular...
Read more >How to manually update a deprecated typings package
I have a NodeJS application that I'm writing in TypeScript. It uses many Node packages. Not all of ...
Read more >Vuex + TypeScript - DEV Community
One of the breaking changes that was introduced is that the library is no more shipped with global typings for this.
Read more >@emotion/react | Yarn - Package Manager
All new changes are now documented in CHANGELOG.md files in each package's directory. v10.0.0 (2018-10-27). Emotion 10 is a big change that we're...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The fix is now published in 29.1.1. Thank you for your patience.
It seems like the reason that this works in
@primer/components
is because@emotion/core
is getting pulled in via a dependency on@storybook/react
. This dependency will update thereact.Attributes
interface to have:https://github.com/emotion-js/emotion/blob/v10/packages/core/types/index.d.ts#L82-L86
As a workaround, I think that adding something like:
should work for most projects - especially ones that don’t have the
styled-components
babel plugin which is needed for thecss
prop anyways.Here is a code-sandbox which shows the fix: https://codesandbox.io/s/jolly-meadow-u4o74
Without the extra
declare module "react"
, we get a compiler error, but with it the app builds as expected.It’s possible that something can be done at the library level to address this, but in the meantime, this should at least be a better solution that adding
ts-ignore
s orcss=""
to work around the issue.