microsoft / microsoft/TypeScript

Typedef of object with generic property fails since 5.1

Open
#54,544 4 comments 0 reactions 1 assignee View on GitHub

@sandersn is already working on this.

Since Jun 12, 2023.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

generic typedef object

🕗 Version & Regression Information
  • This changed between versions 5.0.4 and 5.1.3
⏯ Playground Link

Playground link with relevant code

💻 Code
/** 
 * @typedef {Object} O
 * @property {Array<T>} a Array of T
 * @template T
 */
🙁 Actual behavior

Templated properties produce an error since upgrading TS to 5.1.3

🙂 Expected behavior

Generic properties should work as in 5.0.4

This still works, but it should be functionally equivalent to the typedef above. Though the syntax with @property is preferable as each property can be documented with a description.

/** 
 * @typedef {{a: Array<T>}} O
 * @template T
 */

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.