Skip to content
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

recursive type conversion error #122

Open
andyli opened this issue Oct 2, 2022 · 2 comments
Open

recursive type conversion error #122

andyli opened this issue Oct 2, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@andyli
Copy link

andyli commented Oct 2, 2022

dts2hx failed to process [email protected].

Testing with node 16,

npm i [email protected] [email protected]
npx dts2hx maplibre-gl

output:

> Converting module maplibre-gl
> Error: [TypeScript 3.7] Module '"/test/node_modules/@types/mapbox__point-geometry/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:3:8)
> Error: [TypeScript 3.7] A rest element must be last in a tuple type. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:232:2)
> Error: [TypeScript 3.7] A rest element must be last in a tuple type. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:368:2)
> Error: [TypeScript 3.7] A rest element must be last in a tuple type. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:378:2)
> Error: [TypeScript 3.7] Cannot find name 'GeolocationPosition'. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11363:33)
> Error: [TypeScript 3.7] Cannot find name 'GeolocationPosition'. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11371:23)
> Error: [TypeScript 3.7] Cannot find name 'GeolocationPosition'. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11378:26)
> Error: [TypeScript 3.7] Cannot find name 'GeolocationPosition'. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11385:27)
> Error: [TypeScript 3.7] Cannot find name 'GeolocationPositionError'. (/test/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11388:18)
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
> Error: Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion
...
@andyli
Copy link
Author

andyli commented Oct 3, 2022

creduce (first-time using it, pretty amazing) helped me to get this minimal reproducible example:

type a = boolean
type b = [ a | b ]|[(b|{})[]][][][]|[{b}][][][][][][][][][][][][][][]

It looks like I can get away with a larger stack. It would be nice if I can customize typeStackLimit with a cli argument.

@haxiomic
Copy link
Owner

haxiomic commented Oct 3, 2022

Woah! creduce is amazing! I had no idea you could do that

I tried a larger typeStackLimit (1000) and it just hung until running out of memory. I think there's an infinite type reference loop it's not breaking out of. I do some loop detection but some cases escape this

I've added a debug case 5ad5560 (cd into /test/issue/122 and npm install first), then from vscode you can launch the debug with issue/122

I think what happens is the typescript compiler is lazily creating new types as we explore, so it doesn't realise it's seeing the same type twice

if (stackHasType) {

@haxiomic haxiomic added the bug Something isn't working label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants