-
Notifications
You must be signed in to change notification settings - Fork 708
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
@template {Ctor} [C = Ctor<typeof Complex>] #2384
Comments
Couple bugs here:
|
Indeed, when I compile the types of the JSDoc ".mjs" file to "d.mts" type file, @template Ctor doesn't show up! However, everything else works! TS has no problem inferring Ctor for all methods relying on it. And hovering tips work pretty well too. Anyways, I've decided to abandon JSDoc hacked defaulted parameter type until TS is fully compliant. This is what I'm using now. Not as good though b/c passing a type argument is required: /**
* @typedef {typeof Complex} TC
*/
/**
* @template {Ctor<TC>} C
* @typedef {C} Ctor A generic type representing a `Complex` constructor.
*/
/**
* @template {TC} C
* @typedef {InstanceType<C>} Cinst
* A generic type representing an instance of a constructor `Complex`.
*/
/**
* @template {Ctor<TC>} C
* @typedef {Ctor<C> | {} | void} Cvoid
* A union type representing either a constructor `Complex`, an object, or void.
* Used to hint that a static method can also be invoked "bare".
*/
/**
* @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array |
* Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array |
* BigInt64Array | BigUint64Array} TypedArray
* A union type representing all possible TypedArrays.
*/
/**
* @template {Typed<TypedArray>} T
* @typedef {T} Typed A generic type representing a TypedArray.
*/ |
I still want to fix the first issue, that's an issue in typedoc the second one I plan to open an issue in the TS repo for |
Search terms
@template, @typedef, typeof
Expected Behavior
Create doc.
Actual Behavior
Fails to create doc.
Steps to reproduce the bug
Environment
Minimal MJS code:
TypeDoc doesn't like these 2 @template tags:
It fails to complete the task w/ these 2 errors:
As a workaround, I could move those 2 inside the class itself.
Doing so, TypeDoc fully runs and outputs the doc.
However, it'll simply ignore the existence of both @template tags!
It then displays this extra warning btw:
I wonder if there's some other alternative syntax to constrain a type to Complex type and any possible subclass of it...
The text was updated successfully, but these errors were encountered: