-
Notifications
You must be signed in to change notification settings - Fork 431
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
Map WebIDL object
to TypeScript object
#751
Conversation
This type on the TS side is relatively new, which is probably why it wasn't used in the first place, but gives more precise definitions and, so, better type checking. As a side-effect, fixes microsoft#290 (although in a different way).
65e8c65
to
b59d905
Compare
@saschanaz - do you have a general opinion about tightening the types like this? If these are new APIs, I'm OK with tightening it I think |
@orta These are not new APIs, but it is a relatively new type in TypeScript, and I think it makes sense to use it as it's more precise than |
It will, because this changes property types and return types. I'm afraid that this might break codes in scary way,.. I wonder whether we can first convert argument and dictionary field types, as this certainly provides better type check for them. |
If someone already used If they assumed a different type (e.g. |
Fortunately there are not many other APIs that return |
Yeah, there are not that many aside from |
The only valid use case I could find is |
@saschanaz I'm actually planning to revamp WebAssembly import/export APIs separately in a follow-up PR to turn them into dictionaries with precise allowed types (since not everything can be imported / exported to Wasm). |
Although I'm starting to think that you're right. Maybe it's worth turning just parameters to |
I'm not sure anymore TBH. The |
I'm starting to think that, instead of an @saschanaz what do you think? |
I don't like the readability of I vote to just change parameter types, not return types. |
I’m going to close this since it’s now kind of stale. I’m still not convinced of the value versus readability of |
@sandersn Oh, sorry for never circling back on this. I can definitely see your point about readability. I wonder if something like this would help? interface AnyObject {
[key: string]: any;
}
// ...
declare function f(x: AnyObject): AnyObject; This way 1) |
This type on the TS side is relatively new, which is probably why it wasn't used in the first place, but gives more precise definitions and, so, better type checking.
As a side-effect, fixes #290 (although in a different way).