Allow unicode characters in type name
https://github.com/bcherny/json-schema-to-typescript/blob/d898361ff973d3746ea695f1efce75c975061c6f/src/utils.ts#L164
The member of type name is restricted to only english letters (and some symbol) Typescript now allows unicode characters (doc link)
So, modify this function to allow unicode characters in type name, or as an option?
My scenario: title value is in full chinese, so the result typename is blank, and error happens:
SyntaxError: Declaration or statement expected. (8:1)
6 | */
7 |
> 8 | export type = string
| ^
(Maybe another bug to fix: do not generate blank type name)
A minimium schema would cause this error:
{
"type": "object",
"title": "呵呵",
"properties": {
"some_key": {
"type": "string",
"title": "哈哈"
}
}
}
Sounds good to me! Want to put up a Pull Request?
Fix the blank name bug in #280
Allow unicode is a little complicated, would be later
Thanks for the fix, but I think supporting Unicode (as you suggested) could be a better way to do it. What issues are you running into?
Got a doc: Valid JavaScript variable names in ES2015 Maybe using this code provided in this page to judge a string is a valid identifier is comprehensive, but it's not packed into npm, and while I found some packs:
https://github.com/purplecabbage/valid-identifier https://github.com/YerkoPalma/is-valid-identifier https://github.com/SteveWestbrook/is-valid-var-name
First download for most times, but seems not active; others are not widely adopted (npm downloads) A little hard to choose
I am working on this.
I wanted to confirm that this project targets ES5. I'm considering using Unicode aware regex, but it appears to be only supported from ES2015.
If using ES5, I found https://github.com/mathiasbynens/regexpu.
Additionally, are there any concerns about backwards compatibility or previously generated names?