如何用预定字符串作为关键制作地图?
我想在JSDOC中定义带有预定字符串的地图。例如:
/**
* @typedef {'date' | 'string' | 'integer' | 'float' | 'currency' | 'description'} ColumnTypes
* @type {Map<ColumnTypes, string>}
*/
typeMap = {
'string': 'varchar(max)',
'integer': 'decimal(18,4)',
'date': 'smalldatetime',
}
我尝试这样写,但是我没有看到键的选项列表,例如我使用@type {columntypes}
typescript等效的是:
type ColumnTypes = ('datetime' | 'string' | 'integer' | 'decimal' | 'currency' | 'text')
type DatamapType = {
[key in ColumnTypes]: string;
}
但是我不知道知道如何在JSDOC中写这篇文章。
谢谢
I want to define a map with predetermined strings in JSDoc. Such as:
/**
* @typedef {'date' | 'string' | 'integer' | 'float' | 'currency' | 'description'} ColumnTypes
* @type {Map<ColumnTypes, string>}
*/
typeMap = {
'string': 'varchar(max)',
'integer': 'decimal(18,4)',
'date': 'smalldatetime',
}
I tried to write it like that, but I didn't see the options list for the keys like when I use @type {ColumnTypes}
A typescript equivalent would be:
type ColumnTypes = ('datetime' | 'string' | 'integer' | 'decimal' | 'currency' | 'text')
type DatamapType = {
[key in ColumnTypes]: string;
}
But I don't know how to write that in jsdoc.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下内容可以做到这一点:
The following would do it:
你的语法有点不对劲。你可以这样写。
您可以从此处了解 jsdoc。
Your syntax is a little off. You can write it like this.
You can learn about jsdoc from here.