microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
98.27k stars 12.2k forks source link

when using ts.getJSDocTags, the value of @type is not returned. Is there any solution? #58314

Closed canyuegongzi closed 2 weeks ago

canyuegongzi commented 2 weeks ago

🔎 Search Terms

ts.getJSDocTags、type、get jsDoc、 get js doc tags

🕗 Version & Regression Information

⏯ Playground Link

No response

💻 Code


export default interface CommonHeaderIProps {
  /**
   * name
   *
   * @title name
   * @type string
   * @default true
   */
  testList: TestListData;
}

// code
const jsdoc = ts.getJSDocTags(node);
// code

🙁 Actual behavior

the value of type is not actually returned { title: 'name', type: undefined, default: 'true' }

image

🙂 Expected behavior

Can correctly return the value string of @type annotation instead of returning undefined, example: { title: 'name', type: 'string', default: 'true' }

Additional information about the issue

No response

IllusionMH commented 2 weeks ago

Syntax is @type {typeName} and your example is missing curly braces. Does it work if you add them?

typescript-bot commented 2 weeks ago

This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.