: in typescript destructing

tsc keep complaning about this code of implicit any type:

const updateFile = (type: any, { fsPath: filepath }) => {
.....
}

turns out the : within the destructing is for aliasing.

so the code need to change to

const updateFile = (type: any, { fsPath: filepath }: {fsPath: any}) => {
...
}

quote:

As you can see, component is implicitly any. The : inside of your destructuring assignment in the function arguments is aliasing rather than functioning as a type signature. You could correct it by doing the following:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s