New to typescript (leaving flow) and somewhat dynamoose so this may be a simple question, but how do you assign dynamoose as a type? This is specifically for when dynamoose is passed in as a dependency. I can access some type exports such as Model, Schema, Table etc. but looking through the dynamoose.d.ts file I ses no actual dynamoose type. Am I missing something?
This is what I'm trying to achieve.
import Dynamoose from 'dynamoose'
type Options = {
dynamoose: Dynamoose,
}
const provider = ({ dynamoose }: Options) => {...}
I'm currently getting TS errors as follows:
Cannot use namespace 'Dynamoose' as a type.ts(2709)
Property 'dynamoose' of exported interface has or is using private name 'Dynamoose'.ts(4033)
To get typings for the Dynamoose object.
Operating System:
Operating System Version: MacOS 10.14.x
Node.js version (node -v): 8.12.0
NPM version: (npm -v): 6.4.1
Dynamoose version: 1.8.0
Dynamoose Plugins: n/a
### Other information (if applicable):
-
I fixed this issue in my project by defining Dynamoose type like this: type Dynamoose = typeof dynamoose
Thanks @dolsem I've got that working now - much appreciated!
I've opened a request to fix issues like these in TypeScript by bringing declaration files to parity with language features. https://github.com/microsoft/TypeScript/issues/35822
Most helpful comment
I fixed this issue in my project by defining Dynamoose type like this:
type Dynamoose = typeof dynamoose