question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v27.0.0 breaks TypeScript typings

See original GitHub issue

Describe the bug

  1. 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)
  1. callbacks like onChange/onKeyPress in TextInput 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 codesanbox

Additional context v26 was fine

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jfuchscommented, Sep 21, 2021

The fix is now published in 29.1.1. Thank you for your patience.

2reactions
dmarceycommented, May 11, 2021

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 the react.Attributes interface to have:

declare module 'react' {
  interface DOMAttributes<T> {
    css?: InterpolationWithTheme<any>
  }
}

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:

declare module "react" {
  interface Attributes {
    css?: never;
  }
}

should work for most projects - especially ones that don’t have the styled-components babel plugin which is needed for the css 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-ignores or css="" to work around the issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found