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

[9.4.0] A definition being referenced is lacking #318

Closed
Shin-Ogata opened this issue Apr 17, 2024 · 6 comments
Closed

[9.4.0] A definition being referenced is lacking #318

Shin-Ogata opened this issue Apr 17, 2024 · 6 comments
Assignees
Labels
Milestone

Comments

@Shin-Ogata
Copy link

Bug report
Thank you for the great job.
Since v9.4.0, there is an issue where definitions referenced are lacking and then the generated file is not correct.
When using v9.3.1, the equivalent of Expected output is output.
(In this report, the definition of $StringKeyPathToRecordUnion is missing.)

Input code

  • helper.d.ts
type $UnionToIntersection<T> = (T extends unknown ? (k: T) => void : never) extends (
  k: infer I,
) => void
  ? I
  : never;

type $StringKeyPathToRecordUnion<
  TPath extends string,
  TValue,
> = TPath extends `${infer TKey}.${infer Rest}`
  ? { [Key in TKey]: $StringKeyPathToRecord<Rest, TValue> }
  : { [Key in TPath]: TValue };

export type $StringKeyPathToRecord<TPath extends string, TValue> = $UnionToIntersection<
  $StringKeyPathToRecordUnion<TPath, TValue>
>;
  • index.d.ts
import { $StringKeyPathToRecord } from './helper';
export type Test = $StringKeyPathToRecord<'test', unknown>;

Expected output

export type $UnionToIntersection<T> = (T extends unknown ? (k: T) => void : never) extends (k: infer I) => void ? I : never;
export type $StringKeyPathToRecordUnion<TPath extends string, TValue> = TPath extends `${infer TKey}.${infer Rest}` ? {
	[Key in TKey]: $StringKeyPathToRecord<Rest, TValue>;
} : {
	[Key in TPath]: TValue;
};
export type $StringKeyPathToRecord<TPath extends string, TValue> = $UnionToIntersection<$StringKeyPathToRecordUnion<TPath, TValue>>;
export type Test = $StringKeyPathToRecord<"test", unknown>;

export {};

Actual output

export type $UnionToIntersection<T> = (T extends unknown ? (k: T) => void : never) extends (k: infer I) => void ? I : never;
export type $StringKeyPathToRecord<TPath extends string, TValue> = $UnionToIntersection<$StringKeyPathToRecordUnion<TPath, TValue>>;
export type Test = $StringKeyPathToRecord<"test", unknown>;

export {};

Error Report
N/A. Here is the output using verbose:

> dts-bundle-generator --config ./config.json --verbose

Verbose log enabled
Trying to load config from ./config.json file...
Total entries count=1
Compiling input files...
Using config: tsconfig.json
Skipping compiling the project to generate d.ts because all files in it are d.ts already
Processing types/index.d.ts
======= Processing C:/Users/shin/Projects/GitHub/PR/dts-bundle-generator-lack-defs/types/helper.d.ts =======
======= Processing types/index.d.ts =======
Writing types/index.d.ts -> dist/bundle.d.ts
File checking is skipped (due nothing to check)
Done in 0.65s

How to reproduce the issue

Environment

OS: Windows 10
NodeJS: v20.9.0
npm: v10.1.0
typescript: v5.4.5
dts-bundle-generator: v9.4.0
@timocov timocov added the Bug label Apr 17, 2024
@timocov timocov added this to the 9.4 milestone Apr 17, 2024
@timocov
Copy link
Owner

timocov commented Apr 17, 2024

Broken by 7252a35

@timocov timocov self-assigned this Apr 17, 2024
@timocov
Copy link
Owner

timocov commented Apr 17, 2024

Thanks for reporting the issue! The fix has been deployed in v9.4.1.

@alex-kinokon
Copy link

FYI this fix has a significant overhead that can cause a 4.4x slow down (4.8s → 22s).

@timocov
Copy link
Owner

timocov commented May 5, 2024

@alex-kinokon do you have a repro that I can use to verify a proper fix will work well? If you don't mind, please cut a ticket so we can track it and fix separately.

@alex-kinokon
Copy link

@timocov https://github.com/alex-kinokon/reprod: modify the version dts-bundle-generator to 9.4.0 to see the yarn build time to decrease from 14s to 9s.

@timocov
Copy link
Owner

timocov commented May 6, 2024

@alex-kinokon thanks! I created #322 to investigate possible solution.

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

No branches or pull requests

3 participants