Pelle Jacobs Pelle Jacobs - 7 months ago 36
TypeScript Question

Access exported Typescript interfaces from declaration file

How do we access an interface defined in a declaration file? Eg. I'm having issues with the redux package. Take the store declaration:

export interface Store<S> { ... }

However, in our own code we cannot type variables as

$ error TS2304: Cannot find name 'Store'.

Eg. in:

const addUser = (store: Store<number>) => {
store.dispatch({type: "INCREMENT_USER_COUNT"})

But then, if we remove the
from the declaration file, the typing works fine:

interface Store<S> { ... }

Is there any way for me to actually use this interface as it is defined in the redux declaration file, without having to redefine the


Something that's exported from one file must be imported to be consumed from another file.

Write import { Store } from 'redux'; in the file you're consuming it from to use the type locally.