flow icon indicating copy to clipboard operation
flow copied to clipboard

[WIP] Builtin declaration merging

Open goodmind opened this issue 6 years ago • 7 comments

Somewhat (~~sometimes~~) working fix for https://github.com/facebook/flow/issues/396

goodmind avatar Jul 11 '19 13:07 goodmind

Nice!

tonyn4444 avatar Jul 18 '19 16:07 tonyn4444

Not really, I'm not sure this is right way to do this, but it works at least

goodmind avatar Jul 18 '19 16:07 goodmind

@goodmind any plans to eventually add declaration merging for declare module eventually?

kevinbarabash avatar Jul 21 '19 02:07 kevinbarabash

@kevinbarabash I'm not even sure if I'm implementing it right way, still wait on review from Flow team

goodmind avatar Jul 21 '19 03:07 goodmind

@kevinbarabash just implemented declare module it was pretty easy actually, but it supports only ES declare export from modules, not private interfaces

Also you can't do augmentation in the same file, Flow would complain about re-declaring identifier

The thing you lose with this implementation is ability to completely override class with your own types, it would always merge them into original one

Also you can't really do anything with merging .js.flow files because they are orthogonal to declare module

goodmind avatar Jul 22 '19 05:07 goodmind

I noticed you added GlobalThisT in this PR. It seems independent of the declaration merging. globalThis seems really hard to type properly given that it can have different properties depending on execution context.

kevinbarabash avatar Aug 08 '19 04:08 kevinbarabash

Ah, because I was working on top of my globalThis PR, I noticed that I can do globalThis.HTMLElement = 1; and it would make union of class HTMLElement | number

goodmind avatar Aug 08 '19 11:08 goodmind