Saad
Saad

Reputation: 53969

Flowtype libdefs – How can you import a type from a different libdef?

I'm trying to improve on the koa-router libdefs provided in the Flowtype repository.

Ideally, I would be able to do something like this:

import type { Middleware } from 'koa';

declare module "koa-router" {
  declare class Router {
    get(route: string, handler: Middleware): this;
  }

  declare export default typeof Router;
}

I basically want to use a type from the koa libdefs within the koa-router libdefs. However, when I try the import type { Middleware } from 'koa'; line locally, it seems to make the type definitions break. Is there any way to accomplish what I am trying to do?

Upvotes: 0

Views: 335

Answers (1)

MichaelDeBoey
MichaelDeBoey

Reputation: 2395

Right now there's no good way to have dependencies between libdefs.
flowtype/flow-typed#16 is the issue tracking that and will likely be implemented in flow-typed v3.0.0.

Upvotes: 1

Related Questions