Skip to content

ts@3.9 incompatible #3

Closed
Closed
@yeliex

Description

@yeliex

in ts@3.9, there is a type incompatible with interface declaration merge

// application.ts
class App extends Preon.Application {
    test: string
}

// typings/index.d.ts
declare module 'preon' {
    interface Context {
        app: Application
    }
}

// controller/system.ts
export default class System extends Preon.Controller {
    test(ctx: Preon.Context) {
        ctx.app.test // TS2339: Property 'test' does not exist on type 'Application'.
    }
}

Because the extended class Application is not the same as the original one

For more detail:
microsoft/TypeScript#36696
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#intersections-reduced-by-discriminant-properties

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions