@nxtedition/types
v1.6.13
Published
## Description
Downloads
530
Keywords
Readme
@nxtedition/types
Description
This package contains:
- TypeScript types to be shared between nxtedition packages.
- Runtime validatiors and JSON functions for those types.
Usage
Import types and validators like this in TypeScript:
import type { TemplateRecord } from '@nxtedition/types'
import { isTemplateRecord } from '@nxtedition/types'
const templateRecord: TemplateRecord = { ... }
And like this in JavaScript:
```javascript
import { isTemplateRecord } from '@nxtedition/types'
/**
* @typedef { import("@nxtedition/types").TemplateRecord } TemplateRecord
*/
/** @type {TemplateRecord} */
const templateRecord = { ... }
If bundle size is an issue, you can import only the parts you need like this:
import { isTemplateRecord } from '@nxtedition/types/domains/template'
Development
Generate runtime code
Generally, we only manually specify types in this package. A code generator is used to generate the runtime validators and JSON functions. It will do so for all types that are exported. To run the generator, use the following command:
yarn build
This will build the output to the dist
directory.
Exports
We export all types up to the root of the package, so they can be imported
directly from @nxtedition/types
. This means that all exported types must
be uniquely named.