Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSdoc template defaults syntax not work #46574

Closed
xlfsummer opened this issue Oct 29, 2021 · 2 comments
Closed

JSdoc template defaults syntax not work #46574

xlfsummer opened this issue Oct 29, 2021 · 2 comments

Comments

@xlfsummer
Copy link

Bug Report

🔎 Search Terms

  • default for a type parameter
  • JSdoc default type parameter

🕗 Version & Regression Information

💻 Code

This is the demo code on your website

/** @template [T=object] */
class Cache { // hover `Cache` to see: 'class Cache <T = object>'
    /** @param {T} initial */
    constructor(T) {
    }
}
let c = new Cache()

When I copy those code, and use tsc to generate a .d.ts file. In that .d.ts file, Cache dose not have a generate template.

demo repo

🙁 Actual behavior

output .d.ts:

There is no template defaults, and event no template.

/** @template [T=object] */
export class Cache {
    /** @param {T} initial */
    constructor(T: any);
}

🙂 Expected behavior

output .d.ts should be:

/** @template [T=object] */
export class Cache<T = object> {
    /** @param {T} initial */
    constructor(T: any);
}
@IllusionMH
Copy link
Contributor

There is typo in code constructor(T) should be constructor(initial) (same as in handbook)

And with PR merged on September 9 I think it's implemented only in 4.5. In 4.4.4 you should see an error for [ character.
Works in 4.5.0-beta

@xlfsummer
Copy link
Author

I think it would be better to document a feature after it been released. 🙂

And by the way I'm really exciting about this feature. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants