stampit-org / stampit

OOP is better with stamps: Composable object factories.
https://stampit.js.org
MIT License
3.02k stars 102 forks source link

RFC: TypeScript version bump + Type enhancements #356

Closed sammys closed 1 year ago

sammys commented 1 year ago

I've got a branch implementing types that make IntelliSense give suggestions. Here's a screenshot of SelfAware implemented using these types.

Screenshot 2022-10-28 at 16 34 48

It would require a version bump to TypeScript 4. How does everyone feel about this?

There are only a small number of changes to existing code required in compose/index.ts to make these types possible and I'm pretty sure this won't introduce any breaking changes for existing code since it's types only. If there are any compile problems then they will be easy to fix.

I'm proposing to do the following sequence of PRs if everyone is on board:

  1. If I remember right, @koresar mentioned the most recent package releases were incorrect so I'd like to correct that. If something does need correcting then we probably ought to release new packages after this PR
  2. (optional – will submit a PR for everyone to play with) Switch from Lerna to PNPM workspace... I've been using PNPM workspaces for my own projects and I'm happy to contribute my project structure. The structure builds both ESM & CJS and it supports test driven development and debugging. ref: Lerna is Officially Dead. Long Live Monorepos Update repo + code to use lerna 6.x along with bumping TypeScript, eslint, prettier to latest versions and getting npm audit to pass
  3. #352
  4. Patching the compose package with additional types. Can alternatively put them into another package if anyone thinks that would be better. After this PR I reckon we can release packages for everyone to use while the next PR is finalised
  5. Use the new types in the other (not-compose) packages in the monorepo.

The new types will differentiate a generic Stamp from a Stamp that has a defined descriptor as you see in the screenshot. I've not been able to decide on a name for that differentiating type. I could do with some opinions. Here is my short list in no particular order:

  1. ComposedStamp
  2. InferableStamp
  3. DefinedStamp
koresar commented 1 year ago

I FEEL SUPER PUMPED!!!

I'd give you access to stampit docs (stampit.js.org) too if needed.

sammys commented 1 year ago

Sweet! Definitely will need to document this stuff as it requires coding in a particular way such as using as const for composers and initializers.

OP updated with some more information that I didn't have time to write up when I posted it. Please review and comment.

sammys commented 1 year ago

Enough time has passed for people to comment so I'm pressing ahead with a few changed goals. Main one is to continue using lerna converting the repo to use NPM workspaces. I've added a task list to the OP. PR for task 1 below

sammys commented 1 year ago

Moved to stamp issue queue