Fix flow type errors of all viewers #2039

Merged
btzr-io merged 4 commits from fix-flow into master 2018-10-15 19:19:41 +02:00
btzr-io commented 2018-10-15 03:44:34 +02:00 (Migrated from github.com)

Hacktober fest contribution: Flow type errors #2024

Hacktober fest contribution: Flow type errors #2024
btzr-io commented 2018-10-15 03:50:58 +02:00 (Migrated from github.com)

@seanyesmunt I still don't know how handle react.createRef errors, any ideas?
https://flow.org/en/docs/react/refs/

@seanyesmunt I still don't know how handle `react.createRef` errors, any ideas? https://flow.org/en/docs/react/refs/
btzr-io (Migrated from github.com) reviewed 2018-10-15 03:52:56 +02:00
@ -187,7 +192,39 @@ class ThreeViewer extends React.PureComponent<Props, State> {
}
btzr-io (Migrated from github.com) commented 2018-10-15 03:52:50 +02:00

Should we use this instead of any?
https://www.npmjs.com/package/@types/three

Should we use this instead of `any`? https://www.npmjs.com/package/@types/three
neb-b (Migrated from github.com) reviewed 2018-10-15 04:09:43 +02:00
@ -187,7 +192,39 @@ class ThreeViewer extends React.PureComponent<Props, State> {
}
neb-b (Migrated from github.com) commented 2018-10-15 04:09:42 +02:00

Nice. Definitely

Nice. Definitely
btzr-io (Migrated from github.com) reviewed 2018-10-15 04:47:11 +02:00
@ -187,7 +192,39 @@ class ThreeViewer extends React.PureComponent<Props, State> {
}
btzr-io (Migrated from github.com) commented 2018-10-15 04:47:10 +02:00

Looks like they are TypeScript type definitions 😞

Looks like they are `TypeScript` type definitions :disappointed:
btzr-io (Migrated from github.com) reviewed 2018-10-15 04:50:58 +02:00
@ -187,7 +192,39 @@ class ThreeViewer extends React.PureComponent<Props, State> {
}
btzr-io (Migrated from github.com) commented 2018-10-15 04:50:58 +02:00

I can't find anything for flow 😛

I can't find anything for flow :stuck_out_tongue:
neb-b commented 2018-10-15 06:48:50 +02:00 (Migrated from github.com)

@btzr-io I'm not sure. You can just stick with assigning it in the callback

// constructor
this.textArea = null

// render
<textarea ref={input => this.textArea = input} />

@btzr-io I'm not sure. You can just stick with assigning it in the callback ``` // constructor this.textArea = null // render <textarea ref={input => this.textArea = input} /> ```
btzr-io (Migrated from github.com) reviewed 2018-10-15 07:06:05 +02:00
@ -187,7 +192,39 @@ class ThreeViewer extends React.PureComponent<Props, State> {
}
btzr-io (Migrated from github.com) commented 2018-10-15 07:06:05 +02:00
I can't use / import it: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/three/index.d.ts
neb-b (Migrated from github.com) reviewed 2018-10-15 07:39:20 +02:00
@ -187,7 +192,39 @@ class ThreeViewer extends React.PureComponent<Props, State> {
}
neb-b (Migrated from github.com) commented 2018-10-15 07:39:19 +02:00

I gotcha. Oh well.

I gotcha. Oh well.
chrisza4 commented 2018-10-15 12:23:30 +02:00 (Migrated from github.com)
@btzr-io This may helps https://stackoverflow.com/questions/51518721/flow-type-of-reacts-ref
btzr-io commented 2018-10-15 18:16:56 +02:00 (Migrated from github.com)

@chrisza4 I keep getting this errors if I use createRef:

Cannot call React.createRef because property createRef is missing in object type [1].

     src/renderer/component/viewers/codeViewer.jsx
      29| class CodeViewer extends React.PureComponent<Props> {
      30|   constructor(props: Props) {
      31|     super(props);
      32|     this.textarea = React.createRef();
      33|     this.codeMirror = null;
      34|   }
      35|
Cannot create textarea element because a callable signature is missing in object type [1] but exists in function
type [2] in property ref.

     src/renderer/component/viewers/codeViewer.jsx
 [1]  57|   textarea: { current: null | HTMLTextAreaElement };
      58|   codeMirror: any;
      59|
      60|   render() {
      61|     const { value } = this.props;
      62|     return (
      63|       <div className="code-viewer" onContextMenu={stopContextMenu}>
      64|         <textarea ref={this.textarea} disabled value={value} />
      65|       </div>
      66|     );
      67|   }

@chrisza4 I keep getting this errors if I use `createRef`: ``` Cannot call React.createRef because property createRef is missing in object type [1]. src/renderer/component/viewers/codeViewer.jsx 29| class CodeViewer extends React.PureComponent<Props> { 30| constructor(props: Props) { 31| super(props); 32| this.textarea = React.createRef(); 33| this.codeMirror = null; 34| } 35| ``` ``` Cannot create textarea element because a callable signature is missing in object type [1] but exists in function type [2] in property ref. src/renderer/component/viewers/codeViewer.jsx [1] 57| textarea: { current: null | HTMLTextAreaElement }; 58| codeMirror: any; 59| 60| render() { 61| const { value } = this.props; 62| return ( 63| <div className="code-viewer" onContextMenu={stopContextMenu}> 64| <textarea ref={this.textarea} disabled value={value} /> 65| </div> 66| ); 67| } ```
btzr-io commented 2018-10-15 18:20:26 +02:00 (Migrated from github.com)

@seanyesmunt Ok, it's done.

@seanyesmunt Ok, it's done.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#2039
No description provided.