-
Notifications
You must be signed in to change notification settings - Fork 60
Type of implicit class property is any. #645
Comments
That seems useful!
|
Clutz only sees the types that Closure sees. I tried the below program, which suggests that Closure thinks
|
Yes But we can refer the type from the constructor parameters. Since |
iirc, you need `@const` for Closure to infer this for you.
…On Tue, Jan 2, 2018, 1:21 PM Evan Martin ***@***.***> wrote:
Clutz only sees the types that Closure ses.
I tried the below program, which suggests that Closure thinks this.p_
really is any.
class A {
/** @param {boolean} p */
constructor(p) {
/** @Private */
this.p_ = p;
}
foo() {
this.p_ = 'hi';
}
}
new A(true).foo();
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#645 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAn6ACZy-tZOjAiWdJdV-fiebgYDpsMks5tGp3DgaJpZM4RO27Y>
.
|
Adding a |
I guess, my point is if we start inferring types beyond what Closure does we're moving into the space of implementing our own impl of a type system. I wonder if we could instead get the user to fix their code to have types. For example, isn't there some noImplicitAny-equivalent flag for Closure code? We could ask users to turn that on before migration. |
There are a few options with js-conformance, and they are suggested as part of the migration workflow. I suspect that most teams want to skip the pre-work and go straight to TypeScript, instead of fixing the errors in Closure-land. |
I think the problem is that gents does not run type checking or type
inference at all. That's a conscious choice - you can (could?) only run
type checking after es5 down translation, which we didn't want to do for
more fidelity with the original code.
|
A very common pattern I saw from the recent migrations:
This code is converted to:
Would it make sense to emit this instead?
The renaming the parameter property collapsing is left to TSLint.
The text was updated successfully, but these errors were encountered: