mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
infer from usage JSDoc:Don't emit nested comments (#28161)
* infer from usage JSDoc:Don't emit nested comments
Previously, the trivia on a parameter name would show up inside the
emitted JSDoc comment. If the trivia contained a C-style comment, the
emitted JSDoc comment would be invalid. For example:
```js
function call(callback /*oh no*/) {
return callback(this)
}
```
Emitted this comment:
```js
/**
* @param {(arg0: any) => void} callback /*oh no*/
*/
```
* Remove misleading comment used for debugging.
This commit is contained in:
committed by
GitHub
parent
14c328e706
commit
372c7d9b0c
@@ -219,7 +219,9 @@ namespace ts.codefix {
|
||||
if (param.initializer || getJSDocType(param) || !isIdentifier(param.name)) return;
|
||||
|
||||
const typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host);
|
||||
return typeNode && createJSDocParamTag(param.name, !!inference.isOptional, createJSDocTypeExpression(typeNode), "");
|
||||
const name = getSynthesizedClone(param.name);
|
||||
setEmitFlags(name, EmitFlags.NoComments | EmitFlags.NoNestedComments);
|
||||
return typeNode && createJSDocParamTag(name, !!inference.isOptional, createJSDocTypeExpression(typeNode), "");
|
||||
});
|
||||
addJSDocTags(changes, sourceFile, signature, paramTags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user