You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Javascript+Jsdoc: Not possible to distinguish an omitted type parameter from explicitly specified any. Discrepancy to Typescript: There the omitted type parameter gets typed unknown, and is thus distinguishable
#60786
functioncreate<T>(){}constgNo=create;constgAny=create<any>;constgString=create<string>;constgUnknown=create<unknown>;gNo();// const gNo: <unknown>() => void // <-- Take note! Type is "unknown"!gAny();// const gAny: <any >() => voidgString();// const gString: <string >() => voidgUnknown();// const gUnknown: <unknown>() => void
🙁 Actual behavior
🪢 Javascript + Typed with JSDoc:
Behaves incorrectly ❌.
Here it's NOT possible to distinguish a missing type parameter from that of explicitly given any. Furthermore, the need to use this distinction arose, because the ' "noImplicitAny": true ' does NOT warn of the missing type parameter.
🪢 Typescript:
Behaves correctly ✅.
Here it IS possible to distinguish a missing type parameter from that of explicitly given any. Though here, too, the ' "noImplicitAny": true ' does NOT warn of the missing type parameter.
🙂 Expected behavior
When using JavaScript+Jsdoc, a missing type parameter should be unknown, not any .
That's the way it is already with TypeScript.
Both cases should behave the same, since the type checking is performed by the same system.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
gima
changed the title
Javascript+Jsdoc: Not possible to distinguish an omitted type parameter from any. Discrepancy to Typescript: The type parameters becomes unknown, and is thus distinquishable
Javascript+Jsdoc: Not possible to distinguish an omitted type parameter from any. Discrepancy to Typescript: The type parameters is unknown and is thus distinguishable
Dec 17, 2024
gima
changed the title
Javascript+Jsdoc: Not possible to distinguish an omitted type parameter from any. Discrepancy to Typescript: The type parameters is unknown and is thus distinguishable
Javascript+Jsdoc: Not possible to distinguish an omitted type parameter from explicitly specified any. Discrepancy to Typescript: There the omitted type parameter gets typed unknown, and is thus distinguishable
Dec 18, 2024
🔎 Search Terms
"jsdoc" AND "type parameter" AND "unknown" AND "any" AND ("missing" OR "omitted")
🕗 Version & Regression Information
⏯ Playground Link
Below.
💻 Code
JavaScript + Typed with JSDoc
🔗 Playground link (stable v5.7.2, language:js)
TypeScript
🔗 Playground link (stable v5.7.2, language:ts)
🙁 Actual behavior
🪢 Javascript + Typed with JSDoc:
Behaves incorrectly ❌.
Here it's NOT possible to distinguish a missing type parameter from that of explicitly given
any
.Furthermore, the need to use this distinction arose, because the ' "noImplicitAny": true ' does NOT warn of the missing type parameter.
🪢 Typescript:
Behaves correctly ✅.
Here it IS possible to distinguish a missing type parameter from that of explicitly given
any
.Though here, too, the ' "noImplicitAny": true ' does NOT warn of the missing type parameter.
🙂 Expected behavior
When using JavaScript+Jsdoc, a missing type parameter should be
unknown
, notany
.That's the way it is already with TypeScript.
Both cases should behave the same, since the type checking is performed by the same system.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: