diff --git a/lib/utils.js b/lib/utils.js index 0fd86bd4..c3d96755 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -184,6 +184,10 @@ module.exports = { * @returns {string|null} The key name, or `null` if the name cannot be determined statically. */ getKeyName (property) { + if(!property.key) { + return null; + } + if (!property.computed && property.key.type === 'Identifier') { return property.key.name; } diff --git a/tests/lib/utils.js b/tests/lib/utils.js index fbe78bfc..13830d71 100644 --- a/tests/lib/utils.js +++ b/tests/lib/utils.js @@ -172,6 +172,7 @@ describe('utils', () => { '({ [`foo`]() {} })': 'foo', '({ 5: 1 })': '5', '({ 0x123: 1 })': '291', + '{{ ...{} })': null, '({ [foo]: 1 })': null, '({ [tag`foo`]: 1 })': null, '({ ["foo" + "bar"]: 1 })': null,