-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this
Milestone
Description
Bug Report
π Search Terms
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about jsdoc and export default
β― Playground Link
/**
* The complete Triforce, or one or more components of the Triforce.
*
* @typedef {Object} WishGranter
* @property {boolean} hasCourage - Indicates whether the Courage component is present.
* @property {boolean} hasPower - Indicates whether the Power component is present.
* @property {boolean} hasWisdom - Indicates whether the Wisdom component is present.
*/
/** @type {WishGranter} */
const works = {
hasCourage: true,
foo: false // correctly errors
}
// does not work for export default
/** @type {WishGranter} */
export default {
hasCourage: true,
foo: false // no error
}
// workaround that "breaks" prettier e.g. you can't format anymore as it will remove the `()`
// https://github.com/prettier/prettier/issues/11279
///** @type {WishGranter} */
//export default ({
// // type RocketCliConfig
//});
Compiler Options
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"checkJs": true,
"allowJs": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "ES2017",
"jsx": "react",
"module": "ESNext",
"moduleResolution": "node"
}
}
Playground Link: Provided
π» Code
/** @type {import('rocket/cli').RocketCliConfig} */
export default {
// "no" type - e.g. any
}
π Actual behavior
It does not put any type for export default.
π Expected behavior
/** @type {import('rocket/cli').RocketCliConfig} */
export default {
// type RocketCliConfig
}
π Workaround
A possible workaround is to typecast via ()
but that "breaks" prettier as it will always remove it as "usless" brackets.
See prettier/prettier#11279
/** @type {import('rocket/cli').RocketCliConfig} */
export default ({
// type RocketCliConfig
})
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this