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

This gets confused by "import type" #107

Open
thomasjwebb opened this issue Dec 17, 2021 · 8 comments
Open

This gets confused by "import type" #107

thomasjwebb opened this issue Dec 17, 2021 · 8 comments

Comments

@thomasjwebb
Copy link

I'm trying to use this with antd and get a barrage of errors but it starts with:

Duplicate identifier 'type'. (/Users/pinkboi/src/oea/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts:2:8)

And if you look where in the typescript that's happening it's where it's using import type:

import * as React from 'react';
import type { IconDefinition } from '@ant-design/icons-svg/lib/types';
import type { IconBaseProps } from './Icon';

This is perfectly valid ts as far as I can tell but I do wonder if dts2hx using an older version of typescript might have to do with it. Do issues happen with newer versions?

@thomasjwebb
Copy link
Author

It looks like it was added in 3.8 so maybe just bumping to version 3.8 will fix it. I'll see if I'm able to get building this on my system and if so I'll try that...

@thomasjwebb
Copy link
Author

It seems updating the version fixes this. I still have other issues which I don't think are from this tool:

> Error: [TypeScript 4.5] [object Object] (/Users/pinkboi/src/oea/node_modules/@ant-design/icons/lib/components/Icon.d.ts:19:78)
> Error: [TypeScript 4.5] Cannot find namespace 'JSX'. (/Users/pinkboi/src/oea/node_modules/@ant-design/react-slick/types.d.ts:37:41)
> Error: [TypeScript 4.5] Cannot find namespace 'JSX'. (/Users/pinkboi/src/oea/node_modules/@ant-design/react-slick/types.d.ts:47:35)

but at least that issue goes away. Are there any downsides to at least upgrading to the latest typescript 3 version, 3.9.4?

@haxiomic
Copy link
Owner

Hey thanks for testing updating to 3.8! That’s a super useful datapoint. 3.9.4 may well work too

I’ve been holding back doing this in the main repo because I wanted to go change by change through the compiler API to see if anything critical comes up (since the ts compiler API was a WIP at the time)

however if it works for you maybe we can release it as an alpha version so people can use it in the short term

@haxiomic
Copy link
Owner

If the dts2hx tests are happy on 3.8 or 3.94 let’s deploy it to release

@thomasjwebb
Copy link
Author

Oh yeah I ended up testing with 3.9.4 and that worked for me (aside from other issues I had, which I think are specific to me and not caused by dts2hx).

@haxiomic
Copy link
Owner

haxiomic commented Dec 18, 2021

That’s good news :), i’ll try it early Jan and if it passes the tests I’ll push a new release

@PXshadow - looks like 3.9.4 may work out of the box

@haxiomic haxiomic added this to the 0.20 milestone Apr 12, 2022
@haxiomic
Copy link
Owner

Hey, @PXshadow has let me know about downlevel-dts which can translate TS 4 to TS 3.4 syntax, which could help solve these issues in the short term

@PXshadow
Copy link
Contributor

Thanks for the mention @haxiomic , I'm sure dts2hx could use downlevel-dts as a first compile step assuming it's fast enough and covers the spec better, And in addition as documentation for how to compile new TS 4 syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants