-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation
Milestone
Description
Bug Report
There seems to be an issue with regards to literal types and JSDoc when using export default {}
syntax.
🔎 Search Terms
"jsdoc" and "export default"
Found this related issue: #45233, and Ryan asked me to create a new issue
🕗 Version & Regression Information
It seems to have been introduced in [email protected]. I don't think TS 4.4 had support for typed export default {}
with JSDoc.
- This changed between versions 4.4 and 4.5
⏯ Playground Link
Not possible I think (playground doesn't have plain "js" support?)
💻 Code
In a file "foo.js":
// @ts-check
/**
* @typedef Foo
* @property {string} bar
* @property {'qux'} baz
*/
/** @type {Foo} */
export default {
bar: '42',
baz: 'qux' // 👈 This is NOT ok
// ^^^^^ Type 'string' is not assignable to type '"qux"'
}
/** @type {Foo} */
export const foo = {
bar: '42',
baz: 'qux' // 👈 This is OK
}
🙁 Actual behavior
Type 'string' is not assignable to type '"qux"'
🙂 Expected behavior
no compile error
RyanCavanaugh and a-tarasyuk
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation