unjs / untyped

Generate types and markdown from a config object.
https://untyped.unjs.io/
MIT License
424 stars 19 forks source link

`escapeKey` does not handle properties which begin with a number #146

Open cjpearson opened 7 hours ago

cjpearson commented 7 hours ago

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

cjpearson commented 6 hours ago

Should be fixed with this PR https://github.com/unjs/untyped/pull/143