Closure Compiler marked an optional parameter with a trailing = ({string=}), and older JSDoc carries the habit into object types: {{ street: string, unit: string= }}. TypeScript reads the = as the start of an initializer, which a type cannot have, and reports TS1247, usually together with TS1109 ("Expression expected").
The property stays required, so objects that leave it out then fail too (TS2741 in the example). In a .ts file the same error comes from writing = value inside an interface or type literal.
At a glance
| Code | TS1247 |
|---|---|
| Message | A type literal property cannot have an initializer. |
| TypeScript's category | error |
| Listed under | JavaScript files only |
| Turned on by | No option: every checked file reports it |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0).
What it looks like
/** @typedef {{ street: string, unit: string= }} Address */error TS1247: A type literal property cannot have an initializer.error TS1109: Expression expected.
/** @type {Address} */
export const address = { street: "12 Market St" };error TS2741: Property 'unit' is missing in type '{ street: string; }' but required in type 'Address'.jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["**/*.js"]
} What causes it
- A Closure-style
=after a property type inside a JSDoc object type. - A default value written into a type instead of into the code.
How to fix it
Mark the property optional with ?
Write unit?: string. Put a default value in the code that reads the property (const { unit = "" } = address), not in the type.
/** @typedef {{ street: string, unit?: string }} Address */
/** @type {Address} */
export const address = { street: "12 Market St" };jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["**/*.js"]
} Gotchas
- The
=form is accepted for a whole parameter type,@param {string=} unit, in TypeScript 5.9. TypeScript 7.0 drops much of the Closure syntax, so@param {string} [unit]is the safer spelling (Closure syntax).
Sources
- JSDoc Reference: types · TypeScript handbook
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 21 October 2026.