Allow unicode (Fixes #279)
Fixes #279 and other issues relating to invalid characters in identifiers. It will cover the functionality of #538
This allows any type name that is valid in ES5 by removing invalid characters. Valid characters were determined according to https://mathiasbynens.be/notes/javascript-identifiers.
It uses lodash.template, regenerate, and unicode-11.0.0 to generate the regex in scripts/generate-identifier-regex.ts
It uses code from this gist https://gist.github.com/mathiasbynens/6334847
There is no given license, so I'm not sure if we can use that.
If we can target ES6 or newer, this code can be significantly simplified with Unicode-aware regex.
Would the Unicode-aware regex in the latest commit work? That doesn't require any other packages nor the regex-generation scripts.
I tried using identifierfy but faced some issues when toSafeString was called on the output of toSafeString. Also, it removes more than the minimum in some cases. Ultimately, using identifierfy should work with a few changes to calls of toSafeString
I tried using identifierfy but faced some issues when toSafeString was called on the output of toSafeString. Also, it removes more than the minimum in some cases. Ultimately, using identifierfy should work with a few changes to calls of toSafeString
Great -- want to try doing this?
I've gotten Identifierfy to work
I've had to remove several calls to toSafeString() to prevent double conversion. This should be OK since the parser converts standaloneNames with generateName()
Closing out stale PRs.