@ exodus/ 依赖类型
本包船类型为依赖性注射定义,节点和特征. 类型与 @exodus/dependency-injection编号 :@exodus/argo 以避免循环依赖.
安装
yarn add @exodus/dependency-types
考虑使用 -D 旗在JS项目或TS项目中,不从本包再出出任何种类.
使用量
如果你正在研究一个打字功能,你应该用 satisfies 表达. 以下是一个定义的例子:
import type { Definition } from '@exodus/dependency-types'
const batmobileDefinition = {
// the type guarantees auto-complete and the correct shape of the definition
} as const satisfies Definition
避免使用直接类型的注释,因为它会改变属性类型,例如 id 或者说 type 改为 string 而不是他们的具体价值。 它们是静地产生出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出入出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出出 定义可作为特征的一部分使用,或直接在 依赖注射 容器实例.
要输入特性厂,请使用 Feature 类型 :
import type { Feature } from '@exodus/dependency-types'
const batmobileFeature = () =>
({
id: 'batmobile',
definitions: [],
}) as const satisfies Feature
一个特性可以注册到 @ exodus/ argo 或者说 @ exodus/ 无头。 。 。 .
在联署材料包中,jsdocs可用于记录以下类型:
/**
* @typedef {import('@exodus/dependency-types').Definition} Definition
* @typedef {import('@exodus/dependency-types').Feature} Feature
*/
/** @type {Definition} */
const batmobileDefinition = {
id: 'batmobile',
type: 'module',
// ...
}
const batmobileFeature = () => {
/** @type {Feature} */
const feature = {
id: 'batmobile',
definitions: [],
}
return feature
}