Skip to content

Merging namespaces inside modules #11034

@OliverJAsh

Description

@OliverJAsh

2@rc

Given:

// typings1.d.ts
declare module 'knex' {
    export interface Test {
        foo: string
    }
}
// typings2.d.ts
declare module 'knex' {
    export interface Test {
        bar: string
    }
}
import {Test} from 'knex';
let y: Test = {} as any;
y.foo
y.bar

This works fine. However, given:

// typings1.d.ts
declare module 'knex' {
    namespace Knex {
        const foo: string
        interface Transaction {
            foo: string
        }
    }

    export default Knex;
}
// typings2.d.ts
declare module 'knex' {
    namespace Knex {
        const bar: string
        interface Transaction {
            bar: string
        }
    }
}
import Knex from 'knex';
Knex.foo
Knex.bar // error
let y: Knex.Transaction = {};
y.foo
y.bar  // error

It appears my namespace Knex is not being merged, because I can only access identifiers from typings1.d.ts. Why is this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions