denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
95.43k stars 5.3k forks source link

Dependencies not resolved when combining TypeScript generics and type imports #17239

Closed ayame113 closed 11 months ago

ayame113 commented 1 year ago

I noticed that imports of the form import("module").Foo<import("module").Bar> do not resolve dependencies.

This issue can be reproduced as follows:

// child_a.ts
export type Foo<T> = T;
// child_b.ts
export type Bar = string;
// parent.ts
type A = import("./child_a.ts").Foo<import("./child_b.ts").Bar>;
// ^^^ I expected `string` but got `any`

Type A in parent.ts should be string, but is of type any because the dependencies are not resolved.

image

Additionally, I looked at the output of deno info and it should contain child_b.ts, but it does not.

> deno info parent.ts
local: C:\Users\ayame\work\deno\test\parent.ts
type: TypeScript
dependencies: 1 unique
size: 90B

file:///C:/Users/ayame/work/deno/test/parent.ts (65B)
└── file:///C:/Users/ayame/work/deno/test/child_a.ts (25B)

I found this at https://esm.sh/v102/@octokit/rest@19.0.5/dist-types/index.d.ts . Potentially, many type checks in esm.sh may be disabled.

version: Deno 1.29.1

ayame113 commented 1 year ago

It seems that this issue is still not resolved in v1.35.0. I wonder if it's a swc_ecma_dep_graph bug.