Skip to content

Support ComponentMaps in XP 7.13

Choose a tag to compare

@tajakobsen tajakobsen released this 29 Jun 06:46
· 36 commits to main since this release
a307eb1
  • Some new files will now be generated:
    • /site/layout/index.d.ts
    • /site/pages/index.d.ts
    • /site/parts/index.d.ts
  • These files re-exports the types. So you can now write import type { ArticleList, EmployeeList } from "/site/parts";
  • The new file also declares some global interfaces: XpPartMap, XpLayoutMap and XpPageMap. The @enonic-types libraries after 7.13 will use these interfaces to automatically generate Component-trees that the developer can traverse when doing getComponent() or getComponent()?.page?.... The developer can now do if-statements against component.type and component.descriptor, and will get the correct shape in component.config.
  • This library doesn't generate export interface Article { ... } anymore, but instead generates export type Article = { ... }. The reason is that interface Article would not extend Record<string, unknown>, since interfaces can be expanded by 3rd party code (read project code), TypeScript could not guarantee that the key would be a string. By making this a type instead we lock down the shape, and can use Record<string, unknown> to constrain the shape.

Full Changelog: 2.2.2...2.3.0