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

fix(Input|Button|TextArea): add focus method to typings #1972

Merged
merged 2 commits into from
Aug 20, 2017

Conversation

layershifter
Copy link
Member

Fixes #1970.

@codecov-io
Copy link

codecov-io commented Aug 16, 2017

Codecov Report

Merging #1972 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1972   +/-   ##
======================================
  Coverage    99.8%   99.8%           
======================================
  Files         148     148           
  Lines        2568    2568           
======================================
  Hits         2563    2563           
  Misses          5       5

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4780cd...0d90f0b. Read the comment docs.

@layershifter layershifter changed the title fix(Input): add focus method to typings fix(Input|Button|TextArea): add focus method to typings Aug 16, 2017
@levithomason levithomason merged commit af1f05d into master Aug 20, 2017
@levithomason levithomason deleted the fix/input-typings branch August 20, 2017 17:33
@levithomason
Copy link
Member

Released in semantic-ui-react@0.71.5

@codeaid
Copy link

codeaid commented Aug 24, 2017

This change completely breaks the component. focus attribute alongside others is now always required. <TextArea /> results in:

error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TextArea> & Readonly<{ children?: ReactNode; }> & ...'.
  Type '{}' is not assignable to type 'Readonly<TextArea>'.
    Property 'focus' is missing in type '{}'.

If I add focus={null} it then says:

error TS2322: Type '{ autoHeight: true; disabled: boolean; ref: (textarea: any) => void; value: string; onChange: (ev...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TextArea> & Readonly<{ children?: ReactNode; }> & ...'.
  Type '{ autoHeight: true; disabled: boolean; ref: (textarea: any) => void; value: string; onChange: (ev...' is not assignable to type 'Readonly<TextArea>'.
    Property 'setState' is missing in type '{ autoHeight: true; disabled: boolean; ref: (textarea: any) => void; value: string; onChange: (ev...'.

If you look at the React.Component declaration (which is the class TextArea now extends, you can see that it expects quite a few methods to be present:

class Component<P, S> {
    constructor(props?: P, context?: any);
    setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
    setState<K extends keyof S>(state: Pick<S, K>, callback?: () => any): void;
    forceUpdate(callBack?: () => any): void;
    render(): JSX.Element | null | false;

   // etc.

I've managed to fix it by changing the declaration to the following:

declare class TextArea extends React.Component<TextAreaProps, {}> {
  focus: () => void;
}

It looks like TextArea was copied instead of TextAreaProps.

@codeaid
Copy link

codeaid commented Aug 24, 2017

I've created a pull request to fix the issue. Please find a link to it above this comment.

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

Successfully merging this pull request may close these issues.

None yet

4 participants