-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Error output: Don't deep compare to native objects #26986
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
Comments
I was actually thinking about this on my own today. I think we've tried to be general, and the issue is usually the abstractions over collections. So let's work to try to come up with some Here's my take: you probably don't want to elaborate when comparing anonymous object types to be compared to concrete container types ( Let's dive into that last part? What's "common"? Is it anything with a value-side declaration that has a construct signature? For example, Let's also try to generalize: are we only thinking about anonymous types that come from object literals? Or are we also thinking about not elaborating between any two named types? I think this is harder. For example, you probably don't want to elaborate between a There's a lot here, but I'm really looking for more feedback to make the UX better. Maybe the first idea is good enough, but I'd like to hear your thoughts. |
First I thought to skip elaborate all interfaces in the lib.d.ts but this is bad idea because there is a lot of interfaces like argument options I think we should skip elaborate only well known interfaces. We can mark them with some control comment like Your idea about if an interface has the same class is good. But some interfaces like Bad idea to elaborate Iterable and Array:
Summary: if we can detect that interface is class interface or it is marked with control comment we don't elaborate. |
Some examples: var x: Promise<{ a: number; b: number }> = Promise.resolve({a: 1});
|
TypeScript Version: 3.1.0-dev.201xxxxx
Search Terms:
Currently if we assign not assignable type to a variable, ts shows a deep 'not assignable' error with mark all not compatible fields. Even for a native objects like Array, Promise, Date etc...
But I think this is too noisily. All I want to know is that my type in not assignable to Array. Don't try to compare guts of Array with my type.
Code
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: