Skip to content

Missing declaration in output when importing .d.ts module and using --outdir #32624

@ulrichb

Description

@ulrichb

TypeScript Version: 3.6.0-dev.20190730 (and 3.5.1)

Search Terms: missing declaration module outdir

Code

tsconfig.json:

{
    "compilerOptions": {
        "outDir": "../out",
        "declaration": true
    }
}

main.ts:

import * as SomeDeclarationModule from "./SomeDeclarationModule";

export function fun() : typeof SomeDeclarationModule {
    return { someDeclarationModuleExport: "hi" }
}

SomeDeclarationModule.d.ts

export const someDeclarationModuleExport: string;

Expected behavior:
SomeDeclarationModule.d.ts gets copied into the "outdir".

Actual behavior:
No SomeDeclarationModule.d.ts => an invalid main.d.ts because the module is missing.

The generated main.d.ts:

import * as SomeDeclarationModule from "./SomeDeclarationModule"; // <- !!! missing !!!
export declare function fun(): typeof SomeDeclarationModule;

Playground Link: Sry no repro in playground, but here: typescript-missing-declaration-module-issue.zip (run npx tsc -p src).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions