Skip to content

.d.ts generation error behaviour #31280

Closed

Description

@shrinktofit

TypeScript Version: 3.4.2

Search Terms:
.d.ts; import path

Suppose I have following project structure:

image

The codes are emplaced at https://github.com/shrinktofit/ts-issue .

The generated .d.ts will be:

declare module "nested/shared" {
    export class B {
    }
}
declare module "nested/base" {
    import { B } from "nested/shared";
    export function f(): B;
}
declare module "nested/derived" {
    export function g(): import("nested").B; // LINE 10
}
declare module "nested/index" {
    export * from "nested/base";
    export * from "nested/derived";
    export * from "nested/shared";
}
declare module "index" {
    export * from "nested/index";
}

In line 10, the import("nested").B is an error with message nested is not a module; If I change it to import("nested/index").B, it's fine,

Activity

  1. changed the title [-]Module resolution in .d.ts cannot recognize 'xx/index''[/-] on May 7, 2019
  2. shrinktofit commented on May 7, 2019

    @shrinktofit
    Author

    If I do not export nested/shared in module nested/index, generated code becomes:

    declare module "nested/derived" {
        export function g(): import("nested/shared").B;
    }
    

    and the error disappear.

  3. added
    Bug
    Domain: Declaration Emit
    on May 8, 2019
  4. removed this from the TypeScript 3.7.1 milestone on Oct 17, 2019
  5. 4 remaining items

  6. added
    Rescheduled
    on May 12, 2020
  7. added
    Fix Available
    on Jun 26, 2020
  8. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDomain: Declaration EmitFix AvailableRescheduled

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions