-
Notifications
You must be signed in to change notification settings - Fork 61
Alias colliding names in Closure Library like goog.ui.Component #811
base: master
Are you sure you want to change the base?
Conversation
15ee0a9 to
8a7c2fa
Compare
|
Rebased on latest master |
rkirov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
Interestingly, enough the whitelist used in Google, does not contain those files. Likely we don't have much goog.ui usage with TypeScript these days.
rkirov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at the original issue - 39ca7c2
This workaround should be only needed if the two goog.provides are in separate files (thus two separate --partial invocations). Otherwise, I think the code should emit the workaround based on the local knowledge, and no need for using the whitelist.
In fact, I took your cl and removed the list and your test - goog_ui_component, still produced code that is valid TS. In TS one can merge a class and namespace
declare namespace a {
class b {...}
}
declare namespace a.b {
let x: number;
}
Maybe I am misunderstanding the issue you are working around?
No. This is the generated code and is not valid. In --partial mode, this problem cannot be resolved on the local knowledge, so whitelist is needed. (How can I refer to In non-partial mode, I can guess it to a certain extent (1: is a shadowed symbol, 2: is a constructor, 3: has an enum property that is goog.provide'd), but I do not know whether it is correct for all users, so I think that it is better to limit the target area using whitelist. That makes the code simpler. |
8a7c2fa to
d81d0ea
Compare
d81d0ea to
eb25274
Compare
|
rebased |
eb25274 to
61546ca
Compare
61546ca to
e56656b
Compare
e56656b to
ba4f88e
Compare
ba4f88e to
1bef4d6
Compare
Closure Library causes has 18 errors of TS2417 like the following.
https://github.com/teppeis/closure-library.d.ts/blob/master/errors.txt
In ES (TypeScript) classes, static props of classes are inherited to subclasses.
But in Closure, props of constructor function are not inherited.
For example,
goog.ui.Component.EventTypeis a prop ofgoog.ui.Component, but it's goog.provide'd by itself and not inherited to the subclasses.This PR aliases classes that has such props and causes the errors.
By this change, the props are only imported directory, but not available as static props of classes.