Skip to content

Commit 75c8127

Browse files
committed
fix(valid-types): reallow const type
1 parent 64082aa commit 75c8127

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/rules/valid-types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,5 +988,9 @@ class Test {
988988
* @typedef {Object} module:src/core/Player~mediaFormat
989989
*/
990990
// Settings: {"jsdoc":{"mode":"jsdoc"}}
991+
992+
let SettingName = /** @type {const} */ ({
993+
THEME: `theme`,
994+
})
991995
````
992996

src/rules/validTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export default iterateJsdoc(({
366366

367367
// VALID TYPE
368368
const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);
369-
if (hasTypePosition) {
369+
if (hasTypePosition && (tag.type !== 'const' || tag.tag !== 'type')) {
370370
validTypeParsing(tag.type);
371371
}
372372

test/rules/assertions/validTypes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,5 +2030,12 @@ export default /** @type {import('../index.js').TestCases} */ ({
20302030
},
20312031
},
20322032
},
2033+
{
2034+
code: `
2035+
let SettingName = /** @type {const} */ ({
2036+
THEME: \`theme\`,
2037+
})
2038+
`,
2039+
},
20332040
],
20342041
});

0 commit comments

Comments
 (0)