ulixee / hero

The web browser built for scraping
MIT License
698 stars 33 forks source link

feat(plugins): fix typing and load-order #29

Closed blakebyrnes closed 2 years ago

blakebyrnes commented 2 years ago

I ported over the Secretagent plugin fix and noticed that types weren't working here.

I finally got plugin types to work, but it requires the extended classes to not have a default export. I don't think this matters for the end developer - it just matters in the client codebase for Tab, Hero, and I think we'll want to enable extensions for FrameEnvironment.

I toyed with converting other classes, but it seems like we would need to change whole codebase or it feels off.

calebjclark commented 2 years ago

Is there a Typescript issue open regarding type extensions not working with default exports?

blakebyrnes commented 2 years ago

From typescript manual:

However, there are two limitations to keep in mind:

You can’t declare new top-level declarations in the augmentation — just patches to existing declarations. Default exports also cannot be augmented, only named exports (since you need to augment an export by its exported name, and default is a reserved word - see #14080 for details)

https://github.com/Microsoft/TypeScript/issues/14080