1
votes

I use react/lib/update method with typescript.

I write a definition file for it, like this:

declare module 'react/lib/update' {
  export default function update<S>(value: S, spec: any): S;
}

and, use it like this:

import * as update from 'react/lib/update';

but tsc give me an error:

Cannot invoke an expression whose type lacks a call signature. Type 'typeof 'react/lib/update'' has no compatible call signatures.

It seems my definition file not correct. How to solve this?

1

1 Answers

1
votes

Since you have a default export on the function update, you have to import it like:

import update from 'react/lib/update';