Thanks to visit codestin.com
Credit goes to github.com

Skip to content

After inject withRootStore, ts type inference is broken to any type. #1720

@casamia918

Description

@casamia918

What's going on?

When I define mst models, everything works fine at first. But when I insert .extend(withRootStore) into model definition chain, every model type inference is broken. After withRootStore injected, the store model and rootStore model are inferenced as type any.

Does anybody knows this answer?

Steps to reproduce

  1. Create ignite project
  2. Choose any model you want
  3. import withRootStore and inject with extend method

example

import { withEnvironment, withRootStore } from "../extensions"

export const QuestionStoreModel = types
  .model("QuestionStore")
  .props({
    questions: types.optional(types.array(QuestionModel), []),
  })
  .extend(withEnvironment)
  .extend(withRootStore)
  1. After then, type inference of store models are broken. Infered as Any type. Also type of RootStore is infered as any too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions