Skip to content

Commit 3d632a8

Browse files
committed
wrap numeric key names in quotes
1 parent 5219834 commit 3d632a8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/module-declaration.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ const generateModuleDeclaration = (module, index, API) => {
204204

205205
utils.extendArray(moduleAPI, utils.wrapComment(p.description))
206206
if (module.name === 'process' && p.name === 'versions') return
207-
moduleAPI.push(`${isStatic}${p.name}${isOptional}: ${type};`)
207+
208+
if (p.name.match(/^\d/)) {
209+
// Wrap key in quotes if it starts with a number, e.g. `2d_canvas`
210+
moduleAPI.push(`'${isStatic}${p.name}${isOptional}': ${type};`)
211+
} else {
212+
moduleAPI.push(`${isStatic}${p.name}${isOptional}: ${type};`)
213+
}
208214
})
209215
}
210216

0 commit comments

Comments
 (0)