An identifier can contain a digit, but it cannot be the first character. When given a string such as '2xl', escapeKey does not quote the value.
A better regex might be /^[_$a-zA-Z]\w*$/. It will not match all valid identifiers (e.g. emoji), but it's better to quote unnecessarily than to miss an identifier which should be quoted.
Environment
untyped@1.5.1 nuxt@3.14.149
Reproduction
https://stackblitz.com/edit/github-v2sn8k?file=modules%2Ffoo%2Findex.ts,package.json,nuxt.config.ts
Describe the bug
An identifier can contain a digit, but it cannot be the first character. When given a string such as
'2xl'
,escapeKey
does not quote the value.A better regex might be
/^[_$a-zA-Z]\w*$/
. It will not match all valid identifiers (e.g. emoji), but it's better to quote unnecessarily than to miss an identifier which should be quoted.Additional context
https://github.com/nuxt/nuxt/issues/29921
Logs
No response