Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all Spartacus models augmentable (extendable) #15533

Open
Platonn opened this issue Apr 4, 2022 · 0 comments
Open

Make all Spartacus models augmentable (extendable) #15533

Platonn opened this issue Apr 4, 2022 · 0 comments

Comments

@Platonn
Copy link
Contributor

Platonn commented Apr 4, 2022

Current state

Currently we expose only some models (e.g. Product) to be augmentable (extendable) for customers.

Goal

For the great extensibility experience for customers, ideally we should expose all TS models as augmentable. We don't do it currently, because, according to the current approach, it requires a hassle declaring manually all those models in public_api.ts. (which is cumbersome and prone to leftovers).

The reason extendable models must be declared flatly in public_api.ts

Current limitation of Typescript: the models re-exported in public_api.ts via barrels index.ts files (export * from ./local/file) cannot be augmented. See TS issues:

Details of our current solution (which is used only for some models)

To workaround it, in Spartacus we export manually ONLY SOME most-frequently-extended types in the public_api.ts, and then thanks to our custom builder, we copy-paste those types definitions into the main output .d.ts file in /dist folder of a library.

Let's automate flattening d.ts files

We should research how we can automate flattening d.ts files, so all models are declared in the build output public_api.d.ts

Results of preliminary research:

@Xymmer Xymmer added this to the FUTURE milestone Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants