Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tsc/internal/parser/jsdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ func (p *Parser) parseChildParameterOrPropertyTag(target propertyLikeParse, inde
child := p.tryParseChildTag(target, indent)
if child != nil && name != nil &&
(child.Kind == ast.KindJSDocParameterTag || child.Kind == ast.KindJSDocPropertyTag) &&
!ast.NodeIsMissing(child.Name()) &&
(ast.IsIdentifier(child.Name()) || !textsEqual(name, child.Name().AsQualifiedName().Left)) {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/a.js(5,23): error TS1005: '}' expected.
/a.js(12,23): error TS1005: '}' expected.


==== /a.js (2 errors) ====
/**
* @typedef Sig
* @property {object} Args
* @property {string} Args.name
* @property {function(string)=} Args.onSave
~
!!! error TS1005: '}' expected.
* @property {((v: string) => void)=} Args.onCancel
*/

/**
* @typedef Flat
* @property {string} name
* @property {function(string)=} onSave
~
!!! error TS1005: '}' expected.
* @property {((v: string) => void)=} onCancel
*/

export {};

==== /b.ts (0 errors) ====
import type { Sig, Flat } from "./a.js";

export const nested: Array<keyof Sig["Args"]> = ["name", "onCancel"];
export const flat: Array<keyof Flat> = ["name", "onCancel"];
export const onCancel: Sig["Args"]["onCancel"] = (v: string) => {};

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//// [tests/cases/compiler/jsdocNestedPropertyTagInvalidType.ts] ////

=== /a.js ===

/**
* @typedef Sig
* @property {object} Args
* @property {string} Args.name
* @property {function(string)=} Args.onSave
* @property {((v: string) => void)=} Args.onCancel
*/

/**
* @typedef Flat
* @property {string} name
* @property {function(string)=} onSave
* @property {((v: string) => void)=} onCancel
*/

export {};

=== /b.ts ===
import type { Sig, Flat } from "./a.js";
>Sig : Symbol(Sig, Decl(b.ts, 0, 13))
>Flat : Symbol(Flat, Decl(b.ts, 0, 18))

export const nested: Array<keyof Sig["Args"]> = ["name", "onCancel"];
>nested : Symbol(nested, Decl(b.ts, 2, 12))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
>Sig : Symbol(Sig, Decl(b.ts, 0, 13))

export const flat: Array<keyof Flat> = ["name", "onCancel"];
>flat : Symbol(flat, Decl(b.ts, 3, 12))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
>Flat : Symbol(Flat, Decl(b.ts, 0, 18))

export const onCancel: Sig["Args"]["onCancel"] = (v: string) => {};
>onCancel : Symbol(onCancel, Decl(b.ts, 4, 12))
>Sig : Symbol(Sig, Decl(b.ts, 0, 13))
>v : Symbol(v, Decl(b.ts, 4, 50))

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//// [tests/cases/compiler/jsdocNestedPropertyTagInvalidType.ts] ////

=== /a.js ===

/**
* @typedef Sig
* @property {object} Args
* @property {string} Args.name
* @property {function(string)=} Args.onSave
* @property {((v: string) => void)=} Args.onCancel
*/

/**
* @typedef Flat
* @property {string} name
* @property {function(string)=} onSave
* @property {((v: string) => void)=} onCancel
*/

export {};

=== /b.ts ===
import type { Sig, Flat } from "./a.js";
>Sig : Sig
>Flat : Flat

export const nested: Array<keyof Sig["Args"]> = ["name", "onCancel"];
>nested : ("" | "name" | "onCancel")[]
>["name", "onCancel"] : ("name" | "onCancel")[]
>"name" : "name"
>"onCancel" : "onCancel"

export const flat: Array<keyof Flat> = ["name", "onCancel"];
>flat : (keyof Flat)[]
>["name", "onCancel"] : ("name" | "onCancel")[]
>"name" : "name"
>"onCancel" : "onCancel"

export const onCancel: Sig["Args"]["onCancel"] = (v: string) => {};
>onCancel : ((v: string) => void) | undefined
>(v: string) => {} : (v: string) => void
>v : string

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @strict: true
// @allowJs: true
// @checkJs: true
// @noEmit: true

// @Filename: /a.js
/**
* @typedef Sig
* @property {object} Args
* @property {string} Args.name
* @property {function(string)=} Args.onSave
* @property {((v: string) => void)=} Args.onCancel
*/

/**
* @typedef Flat
* @property {string} name
* @property {function(string)=} onSave
* @property {((v: string) => void)=} onCancel
*/

export {};

// @Filename: /b.ts
import type { Sig, Flat } from "./a.js";

export const nested: Array<keyof Sig["Args"]> = ["name", "onCancel"];
export const flat: Array<keyof Flat> = ["name", "onCancel"];
export const onCancel: Sig["Args"]["onCancel"] = (v: string) => {};