Shared type definition for core libraries.
npm install @enonic-types/core> TypeScript definitions that are shared between libraries and represent core
> data structures.
``bash`
npm i --save-dev @enonic-types/core
> It is not necessary to include this dependency into your project, as all
> libraries export related core types, e.g. Content library exports Content
> type.
All core types can be imported using ES6-style import:
`ts`
import type {Content} from '@enonic-types/core';
Content contains the x property, that has a very special XpXData type.
XpXData is an interface, that is added to the global scope, so it can beXpXData
modified using the declaration merging.
This allows you to set the shape of the XData in your project, simply by
declaring the like this:
`ts`
declare global {
interface XpXData {
'com-mysite-app': {
metadata: {
metaTagTitle: string;
metaTagImageId: string;
}
}
}
}
Content is a complex type that contains unions and maps, that are not exported, but may be needed during the development. Actually, these types can easily be retrieved from the Content itself:
`ts
import type {Content} from '@enonic-types/core';
type Attachments = Content['attachments'];
type ContentInheritType = Content['inherit'];
type Workflow = Content['workflow'];
``