xaviergonz / mobx-keystone

A MobX powered state management solution based on data trees with first class support for Typescript, support for snapshots, patches and much more
https://mobx-keystone.js.org
MIT License
546 stars 24 forks source link

Does it support Typescript 5.X features? #526

Closed steschi closed 1 year ago

steschi commented 1 year ago

Hey all!

Currently evaluating mobx-keystone for a project. We are already using typescript 5.1.6 and the "new" decorators as well as "moduleResolution": "bundler" in tsconfig.json but this yields some issues when importing mobx-keystone. Should this work already? Or is mobx-keystone not ready for this yet?

TS7016: Could not find a declaration file for module mobx-keystone:
./node_modules/mobx-keystone/dist/mobx-keystone.esm.mjs implicitly has an  any  type.

There are types at ./node_modules/mobx-keystone/dist/types/index.d.ts, 
but this result could not be resolved when respecting package.json exports. 
The mobx-keystone library may need to update its package.json or typings.

I think "types": "./dist/types/index.d.ts" is missing in the exports tag of package.json. If I add it manually the resolve works as expected.

"exports": {
    "./package.json": "./package.json",
    ".": {
      "import": "./dist/mobx-keystone.esm.mjs",
      "require": "./dist/mobx-keystone.umd.js",
      "script": "./dist/mobx-keystone.umd.js",
      "default": "./dist/mobx-keystone.esm.mjs",
      "types": "./dist/types/index.d.ts"
    }
  }
xaviergonz commented 1 year ago

The module resolution issue seems to be a bug. I'll release a new version to fix it.

About the new decorators, the lib depends on mobx so mobx itself needs to support the new decorators before any work can be done on this side 😢

xaviergonz commented 1 year ago

I think the bundler part should be fixed now in 1.6.4

steschi commented 1 year ago

Thanks for solving this so quickly. 1.6.4 works for me now. It looks like the new decorators are at least considered by mobx so im looking forward to it.