dart-archive / js_facade_gen

Generates package:js Javascript interop facades for arbitrary TypeScript libraries
Apache License 2.0
162 stars 29 forks source link

Update handling of invalid identifiers #63

Open derekxu16 opened 4 years ago

derekxu16 commented 4 years ago

Certain identifiers are acceptable in JavaScript but not in Dart. One common case where these identifiers get used is in Object properties. obj[string] can be used to give an object a property with any name.

In dart2js, JS$ can be prepended to fix certain invalid identifiers, but this won't work for identifiers that contain invalid characters. Additionally, DDC no longer supports JS$. Instead of using JS$, the generator should be able to determine which invalid identifiers are renamable and expose extension methods that rename them (by accessing the JS entity with js_util). For identifiers that aren't renamable, it should suppress that declaration and emit a warning.