镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

.d.ts generation error behaviour #31280

Description

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''[/-] [+].d.ts generation error behaviour[/+] 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. removed this from the TypeScript 3.7.1 milestone on Oct 17, 2019
  4. 4 remaining items

  5. 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

BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions