sequelize.js - JSDoc如何在不创建新的typedef的情况下将成员添加到类型
问题描述
据说我有一种叫做 A 和 B 的类型
/**
* @typedef A
* @type {object}
* @property {String} id this is id A
* @property {String} name this is name A
* @property {String} child_id this is id B
*/
/**
* @typedef B
* @type {object}
* @property {String} id this is id A
* @property {Number} qty this is qty B
*/
无论如何我可以有类似的东西
{
id:"a",
name:"a",
B:{
id: "b",
qty:0
}
}
不重写typedef?
我有一个返回 Sequelize Object 的函数,这就是为什么
解决方案
最后我所做的是使用 & 关键字相交
/**
* @typedef A
* @type {object}
* @property {String} id this is id A
* @property {String} name this is name A
* @property {String} child_id this is id B
*/
/**
* @typedef B
* @type {object}
* @property {String} id this is id A
* @property {Number} qty this is qty B
*/
我可以在我的定义中说
@returns {A & { B : B }}
或创建新的 typedef
/**
* @typedef C
* @type {object}
* @property {A & {B:B}} B inside A relation
*/
推荐阅读
- ubuntu - Ubuntu 19.10 上的 OpenModelica
- java - 尝试将数据从活动发送到片段时未找到视图错误
- c++ - getline 方法仅在嵌套循环中工作一次
- php - 如何在单独的 php 文件的输入值属性中显示结果?
- postgresql - 强制对 HSQLDB 中的列名进行明确引用
- sql - 关键字“ON”附近的语法不正确 - 尝试将子数据添加到现有行
- python - 如何在 Notebook 小部件 tkinter 中将选项卡(带文本)旋转 90°?
- python - 使用多个异步程序时的 aiomysql 行锁定
- python-3.x - 连续函数乘以离散函数时如何使用scipy积分
- python - For Loop 有 2 个变量,但只想枚举其中 1 个