bloomberg / ts-blank-space

A small, fast, pure JavaScript type-stripper that uses the official TypeScript parser.
https://bloomberg.github.io/ts-blank-space
Apache License 2.0
544 stars 8 forks source link

fix: avoid ASI hazard with computed class members #22

Closed acutmore closed 1 week ago

acutmore commented 1 week ago

Fixes #21

Describe your changes This change defends against a ASI hazard. When a computed class member name has a leading type modifier (public/private/protected/readonly/override) a ; is inserted in it's place to avoid being interpreted as index lookup of the previous class member. For example:

class C {
    f = 1
    public ["computed"] = 2
}

now becomes:

class C {
    f = 1
    ;      ["computed"] = 2
}

Testing performed New test fixtures have been added and all ecosystem tests were run. All tests passing.