Dot versus Colon 2 - #111
Conversation
|
Here's a few issues I've found:
Sorry if I seem overly critical, I just like to cover the edge cases 😛 |
|
I actually remembered why we use These other ones indeed seem like issues and I will have a look at how to resolve those when I have time. |
|
Hmm, that does make sense for |
|
@apemanzilla @lolleko tried to solve by transpiling lambda properties with |
dmarcuse
left a comment
There was a problem hiding this comment.
Thanks, this looks pretty good: here's the results of my testing.
- Classes and interfaces are working, including inheritance (might want to add to the test)
- Simple type literals are working (also might want to add to the test)
- Intersections and unions (and likely other advanced types) are not working, but with classes/interfaces and inheritance this can typically be worked around and would probably require a lot of effort to fix anyways
| } | ||
|
|
||
| if (expType.symbol && (expType.symbol.flags & ts.SymbolFlags.Namespace)) { | ||
| const expType2 = this.checker.getTypeAtLocation(node.expression); |
There was a problem hiding this comment.
It might be worth renaming expType and expType2 to something more descriptive - such as containerType and functionType respectively.
| } | ||
|
|
||
| if (expType.symbol && (expType.symbol.flags & ts.SymbolFlags.Namespace)) { | ||
| const expType2 = this.checker.getTypeAtLocation(node.expression); |
| interfaceInstance.colonMethod(); | ||
| interfaceInstance.dotMethod(); | ||
| TestNameSpace.dotMethod(); | ||
| TestNameSpace.dotMethod2(); |
There was a problem hiding this comment.
Not sure how much sense it makes but maybe add some functional tests too. Probably not that important.
|
Is there anything still holding this back? |
|
Found another minor edge case. If you have an instance of an interface extending from two interfaces defining the same method as an arrow function and regular function, it will use the first parent interface to determine the function type. I can't think of any cases where this really matters, though. declare interface A2 {
method: () => void;
}
declare interface B2 {
method(): void;
}
declare interface Thing extends B2, A2 {} // swapping B2 and A2 here changes transpilation
declare const thing: Thing;
thing.method(); |
|
@apemanzilla I will merge this once I added some functional tests and had a quick look if there is any easy way to deal with union types. |
|
Thank you! |
Counter proposal to #109 and #108