enonic-types
Advanced tools
Changelog
0.5.0
New global
maps are used for registering shapes of Content Types, as well as the shape of Site.config
and
Content.x
.
Note If you are using xp-codegen-plugin@2.0.0 all the
global
declarations mentioned below are automatically generated for you based on the xml-files in your project! :tada:
The type system can now look up the content types when using contentLib.query()
with the contentTypes
parameter set.
For the type system to know about the shape of a content type, we first need to register it. This is done in a global declaration.
export type Article = import("./article").Article
export type Employee = import("./employee").Employee
declare global {
namespace XP {
interface ContentTypes {
"com.mysite:article": Article;
"com.mysite:employee": Employee;
}
}
}
This declaration only needs to be done once in your code base, and every XP.ContentTypes
will now be merged to one
interface.