haxiomic / dts2hx

Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
MIT License
131 stars 8 forks source link

js.lib.AsyncIterator is redefined #98

Closed andyli closed 2 years ago

andyli commented 2 years ago

build.hxml

--class-path lib
--js dummy.js
--no-output
--macro include("global")
--macro include("js")
--macro include("node")

To reproduce,

$ npx dts2hx @types/node --noLibWrap --output lib
$ haxe build.hxml
(unknown) : Type name js.lib.AsyncIterator is redefined from module js.lib.AsyncIterator

The cause is Haxe std lib defined js.lib.AsyncIterator in std/js/lib/Iterator.hx, and somehow dts2hx generates another AsyncIterator.

haxiomic commented 2 years ago

Still thinking on best resolution, but talking through the problem:

So we probably have to generate an AsyncIterator anyway but it should be renamed to avoid the clash

haxiomic commented 2 years ago

This is fixed in 0.16.1, we still generate our version of AsyncIterator because other types rely on the type parameters being correct but it's renamed to AsyncIterator_

Running your test build.hxml now passes for me, but I changed --macro include("js") to --macro include("js.lib") to avoid compiler issues with HxOverrides.hx

andyli commented 2 years ago

Works perfectly. Thanks!