Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

7.1 version breaks TypeScript projects by declaring optional properties as required #146

Open
ngbrown opened this issue Jul 13, 2020 · 5 comments
Labels

Comments

@ngbrown
Copy link

ngbrown commented Jul 13, 2020

There is no v7.1 tag in this repository, but it is appearing as latest on npm.

Once I updated my project to that version, I am getting the following error:

TypeScript error in D:/dev/xxxx.tsx(64,10):
Property 'translate' is missing in type '{ onFocus: (event: {}) => void; type: string; className: string; rows: number; }' but required in type 'Pick<HTMLProps<HT
MLTextAreaElement>, "default" | "key" | "value" | "is" | "cite" | "data" | "form" | "label" | "span" | "style" | "summary" | "title" | ... 347 more ... | "wmode">
'.  TS2741

when being used like this:

        <TextareaAutosize
          type="text"
          className="form-control"
          rows={4}
        />

Even adding a translate={'no'} property doesn't resolve the error.

Going back to [email protected] (without the translate property) also resolves the error.

@ngbrown ngbrown changed the title 7.1 version breaks TypeScript projects. 7.1 version breaks TypeScript projects by declaring optional properties as required Jul 13, 2020
@giogonzo
Copy link
Member

Hi @ngbrown I can't repro, could you provide some info on your setup / TS version?

@ngbrown
Copy link
Author

ngbrown commented Jul 14, 2020

I'm using [email protected] in an ejected create-react-app project. It's not up to date on every other dependency, so if it's not this slightly older typescript version, I can try to put together a reproduction.

@ngbrown
Copy link
Author

ngbrown commented Jul 22, 2020

When updated to [email protected], it still has this error.

I'm using the older [email protected] and [email protected], with the corresponding @types/[email protected] and @types/[email protected]. I'm doing this because there are still some now obsoleted lifecycle methods in my dependencies.

When I update to the latest react, react-dom, and types, then the error clears.

I think this must be because this library is requiring a newer react type dependency that has added translate to HTMLAttributes<T>.

Maybe relying on the oldest possible version of the types would fix this? Or using a peer-dependency instead?

@peterj35
Copy link

peterj35 commented Aug 5, 2020

I'm getting an error likely related to this, with v7.1:

TypeScript error in /Users/peter/workspace/packages/web-ui/src/components/Form.tsx(562,8):
Type '{ name?: string | undefined; form?: string | undefined; style?: CSSProperties | undefined; title?: string | undefined; key?: string | number | undefined; autoComplete?: string | undefined; ... 262 more ...; ref: ((instance: HTMLTextAreaElement | null) => void) | ... 1 more ... | null; }' is not assignable to type 'Pick<HTMLProps<HTMLTextAreaElement>, "name" | "cite" | "data" | "form" | "label" | "span" | "style" | "summary" | "title" | "pattern" | "key" | ... 348 more ... | "translate">'.
  Types of property 'inputMode' are incompatible.
    Type 'string | undefined' is not assignable to type '"email" | "text" | "none" | "search" | "tel" | "url" | "numeric" | "decimal" | undefined'.
      Type 'string' is not assignable to type '"email" | "text" | "none" | "search" | "tel" | "url" | "numeric" | "decimal" | undefined'.

Just using TextareaAutosize with TS as (not providing an inputMode):

<TextareaAutosize ref={ref} {...rest} />

@markathomas
Copy link

Same issue here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants