AHOYAHOY
AHOYAHOY

Reputation: 1847

mobx state tree as module in typescript

I cannot export mobx model as module. I found some advice but I dont know how to do it.

import { types } from 'mobx-state-tree'

export default types.model('Test')

[ts] Default export of the module has or is using private name 'IModelType'.

or

const model = types.model('Login')
export default model

[ts] Exported variable 'model' has or is using name 'IModelType' from external module "..." but cannot be named.

Upvotes: 1

Views: 359

Answers (1)

Jules Sam. Randolph
Jules Sam. Randolph

Reputation: 4230

You have set "declaration": true in your tsconfig.json and you need to explicitly export IModelType so that the consumer of your library have the appropriate typings.

Either add

export { IModelType } from 'mobx-state-tree'

to this source file or set "declaration": false in your tsconfig.json if you're not publishing your library.

Upvotes: 1

Related Questions