我可以使用 JSDoc 将 TypeScript 文件转换为 JavaScript 文件吗?
例如,如果我有这个main.ts
文件:
let x: string = "hello";
// This could be number or array of numbers
let y: number | number[];
Run Code Online (Sandbox Code Playgroud)
它将被转换为类似这样的main.js
文件:
/**
* @type {string}
*/
let x = "hello";
/**
* This could be number or array of numbers
* @type {number | number[]}
*/
let y;
Run Code Online (Sandbox Code Playgroud)
等等。
有没有办法做到这一点?
谢谢!
给定以下代码,当我们调用该baz
函数时,预先输入将显示“a”和“b”作为可能的值。
但是,如果我想为每个值提供附加文档,我该怎么做?例如,如果这样的行为是所需的行为:
我认为我应该提供更多关于我正在尝试做的事情及其原因的背景信息:
考虑以下示例:
const paintColor = {
/** This color is good fo X */
Waltz: "#d9e5d7",
/** This color is good fo Y */
"Indiana Clay": "#ed7c4b",
/** This color is good fo Z */
Odyssey: "#575b6a"
};
const locations = {
/** There are no good school at this location*/
City: "123 city center road",
/** There are lots of parking at this location but it is very far*/
West: "245 some other road"
}; …
Run Code Online (Sandbox Code Playgroud) 我想将一个属性(例如qux
下面的)标记为已弃用:
/**
@typedef {object} Foo
@property {string} bar
@property {symbol} qux - How to deprecate it?
@deprecated @property {symbol} qux2 - Doesn't work
@property {symbol} qux3 @deprecated - This marks the whole of Foo as deprecated
*/
Run Code Online (Sandbox Code Playgroud)
我应该提到,我想在 JSDoc 注释中执行此操作,而不是使用 TypeScript。