In @typedef tag, handle property with no type (#19013)
This commit is contained in:
parent
e821c2b6e9
commit
8a55baf9a3
|
@ -2146,7 +2146,7 @@ namespace ts {
|
|||
// falls through
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
const propTag = node as JSDocPropertyLikeTag;
|
||||
const flags = propTag.isBracketed || propTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType ?
|
||||
const flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType ?
|
||||
SymbolFlags.Property | SymbolFlags.Optional :
|
||||
SymbolFlags.Property;
|
||||
return declareSymbolAndAddToSymbolTable(propTag, flags, SymbolFlags.PropertyExcludes);
|
||||
|
|
|
@ -6699,7 +6699,7 @@ namespace ts {
|
|||
if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) {
|
||||
jsdocTypeLiteral.isArrayType = true;
|
||||
}
|
||||
typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
|
||||
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
|
||||
childTypeTag.typeExpression :
|
||||
finishNode(jsdocTypeLiteral);
|
||||
}
|
||||
|
|
|
@ -2194,7 +2194,7 @@ namespace ts {
|
|||
export interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
|
||||
parent: JSDoc;
|
||||
name: EntityName;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
typeExpression?: JSDocTypeExpression;
|
||||
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
||||
isNameFirst: boolean;
|
||||
isBracketed: boolean;
|
||||
|
|
|
@ -1473,7 +1473,7 @@ declare namespace ts {
|
|||
interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
|
||||
parent: JSDoc;
|
||||
name: EntityName;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
typeExpression?: JSDocTypeExpression;
|
||||
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
||||
isNameFirst: boolean;
|
||||
isBracketed: boolean;
|
||||
|
|
|
@ -1473,7 +1473,7 @@ declare namespace ts {
|
|||
interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
|
||||
parent: JSDoc;
|
||||
name: EntityName;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
typeExpression?: JSDocTypeExpression;
|
||||
/** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */
|
||||
isNameFirst: boolean;
|
||||
isBracketed: boolean;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
=== /a.js ===
|
||||
/**
|
||||
* @typedef Foo
|
||||
* @property foo
|
||||
*/
|
||||
|
||||
/** @type {Foo} */
|
||||
const x = { foo: 0 };
|
||||
>x : Symbol(x, Decl(a.js, 6, 5))
|
||||
>foo : Symbol(foo, Decl(a.js, 6, 11))
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
=== /a.js ===
|
||||
/**
|
||||
* @typedef Foo
|
||||
* @property foo
|
||||
*/
|
||||
|
||||
/** @type {Foo} */
|
||||
const x = { foo: 0 };
|
||||
>x : { foo: any; }
|
||||
>{ foo: 0 } : { foo: number; }
|
||||
>foo : number
|
||||
>0 : 0
|
||||
|
12
tests/cases/compiler/jsdocTypedef_propertyWithNoType.ts
Normal file
12
tests/cases/compiler/jsdocTypedef_propertyWithNoType.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
|
||||
// @Filename: /a.js
|
||||
/**
|
||||
* @typedef Foo
|
||||
* @property foo
|
||||
*/
|
||||
|
||||
/** @type {Foo} */
|
||||
const x = { foo: 0 };
|
Loading…
Reference in a new issue