New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn when properties are accessed through ['literal'] #23
Comments
This feature is quite weird. If you create an intermediate variable ( |
Does it output a quoted access, or a non quoted? If it compiles into non Evan Martin notifications@github.com schrieb am Fr., 18. März 2016, 09:23:
|
It outputs quoted. |
Got a CL ready that checks this. I am pretty scared I'm accidentally warning on some other, legal thing, so I think I want to put this behind a temporary flag. |
Another antipattern I spotted in the same vein: let data: {[key: string]: string} = {
foo: "bar",
}; I think you need to quote |
If you have an |
Depends on the expected use of any, I guess? But sounds reasonable, if you
want actual properties, you can still cast to the actual type. We'd have to
see what the impact on a large code base would be.
|
Randomly stumbled on this bug, through our documentation. Current status is that this is handled by 'https://tsetse.info/property-renaming-safe'. In any case, we definitely don't want to add such checks into tsickle - tslint and/or tsetse is the right layer for checks. |
Typescript allows property access with square brackets and string literal to access regular properties (ref https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#4.13)
so the following is valid TS
but this will fail spectacularly post minification with closure.
The text was updated successfully, but these errors were encountered: