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

Generics extended with declare module statement aren't included #305

Closed
tuomokar opened this issue Mar 2, 2024 · 2 comments · Fixed by #316
Closed

Generics extended with declare module statement aren't included #305

tuomokar opened this issue Mar 2, 2024 · 2 comments · Fixed by #316
Assignees
Labels
Milestone

Comments

@tuomokar
Copy link

tuomokar commented Mar 2, 2024

Bug report

When using the parameter --inline-declare-externals, the produced declare module statement can miss some imports if the statement includes types that extend another type.

Input code

import { RowData } from '@tanstack/react-table';

declare module '@tanstack/table-core' {
    interface TableMeta<TData extends RowData> {
        stickyFilters?: boolean;
    }
}

Expected output

// RowData is imported
import { RowData } from '@tanstack/react-table';

declare module "@tanstack/table-core" {
    interface TableMeta<TData extends RowData> {
        stickyFilters?: boolean;
    }
}

Actual output

// RowData is not imported
declare module "@tanstack/table-core" {
    interface TableMeta<TData extends RowData> {
        stickyFilters?: boolean;
    }
}

Additional context

When building, these errors appear:

node_modules/@tanstack/table-core/build/lib/types.d.ts(17,18): error TS2428: All declarations of 'TableMeta' must have identical type parameters.
ReactTable.d.ts(7,12): error TS2428: All declarations of 'TableMeta' must have identical type parameters.
ReactTable.d.ts(7,36): error TS2304: Cannot find name 'RowData'.

I made a small repository to reproduce the issue. It can be found from here.

Thank you for your time in advance!

@timocov timocov added the Bug label Mar 3, 2024
@timocov timocov added this to the 9.4 milestone Mar 9, 2024
@timocov
Copy link
Owner

timocov commented Mar 24, 2024

A note for myself (or anyone who's concerned) about the issue: currently the tool uses only root file exports to detect whether a type/value is used or not and thus whether it should be added to the bundle (via either way e.g. importing or inlining). With --inline-declare-externals we need to consider all these "declare externals" as well (it might be tricky tho as collecting a list of such externals is done at the same time as processing all files, so we might need to split this into 2 phases).

@timocov timocov self-assigned this Apr 1, 2024
timocov added a commit that referenced this issue Apr 15, 2024
…re used in `declare module` statements only

Fixes #305
stepankuzmin pushed a commit to stepankuzmin/dts-bundle-generator that referenced this issue Apr 15, 2024
@timocov
Copy link
Owner

timocov commented Apr 15, 2024

The fix has been published in 9.4.0 version.

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