Skip to content

Commit fb1a42b

Browse files
committed
(lint/types): explicit return types for all functions
- reuse React.Component types where possible, just like with the SignaturePad types
1 parent a20d7ad commit fb1a42b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@ export class SignatureCanvas extends Component<SignatureCanvasProps> {
3333
_sigPad: SignaturePad = {} as SignaturePad
3434
_canvas: HTMLCanvasElement = {} as HTMLCanvasElement
3535

36-
private readonly setRef = (ref: HTMLCanvasElement | null) => {
36+
private readonly setRef = (ref: HTMLCanvasElement | null): void => {
3737
if (ref) {
3838
this._canvas = ref
3939
}
4040
}
4141

42-
_excludeOurProps = () => {
42+
_excludeOurProps = (): SignaturePad.SignaturePadOptions => {
4343
const { canvasProps, clearOnResize, ...sigPadProps } = this.props
4444
return sigPadProps
4545
}
4646

47-
componentDidMount () {
47+
componentDidMount: Component['componentDidMount'] = () => {
4848
this._sigPad = new SignaturePad(this._canvas, this._excludeOurProps())
4949
this._resizeCanvas()
5050
this.on()
5151
}
5252

53-
componentWillUnmount () {
53+
componentWillUnmount: Component['componentWillUnmount'] = () => {
5454
this.off()
5555
}
5656

5757
// propagate prop updates to SignaturePad
58-
componentDidUpdate () {
58+
componentDidUpdate: Component['componentDidUpdate'] = () => {
5959
Object.assign(this._sigPad, this._excludeOurProps())
6060
}
6161

@@ -80,14 +80,14 @@ export class SignatureCanvas extends Component<SignatureCanvasProps> {
8080
return this._sigPad
8181
}
8282

83-
_checkClearOnResize = () => {
83+
_checkClearOnResize = (): void => {
8484
if (!this.props.clearOnResize) {
8585
return
8686
}
8787
this._resizeCanvas()
8888
}
8989

90-
_resizeCanvas = () => {
90+
_resizeCanvas = (): void => {
9191
const canvasProps = this.props.canvasProps || {}
9292
const { width, height } = canvasProps
9393
// don't resize if the canvas has fixed width and height
@@ -111,7 +111,7 @@ export class SignatureCanvas extends Component<SignatureCanvasProps> {
111111
this.clear()
112112
}
113113

114-
render () {
114+
render: Component['render'] = () => {
115115
const { canvasProps } = this.props
116116
return <canvas ref={this.setRef} {...canvasProps} />
117117
}

0 commit comments

Comments
 (0)