-1

Type 'string' does not satisfy the constraint 'unknown[]':

const query = db.prepareQuery<string>(

TS2707 [ERROR]: Generic type 'RouterContext<R, P, S>' requires between 1 and 3 type arguments.

{ request, response, state }: RouterContext,

TS2532 [ERROR]: Object is possibly 'undefined'.

data.negative = negative.map((w) => w.word);

I have a deno api using oak and when i upgraded recently to Deno 1.18 I get all these errors now.

chovy
  • 72,281
  • 52
  • 227
  • 295

1 Answers1

3

Below is the interface of RouterContext


export interface RouterContext<
  R extends string,
  P extends RouteParams<R> = RouteParams<R>,
  // deno-lint-ignore no-explicit-any
  S extends State = Record<string, any>,
> extends Context<S> {
  /** When matching the route, an array of the capturing groups from the regular
   * expression. */
  captures: string[];

  /** The routes that were matched for this request. */
  matched?: Layer<R, P, S>[];

  /** Any parameters parsed from the route when matched. */
  params: P;

  /** A reference to the router instance. */
  router: Router;

  /** If the matched route has a `name`, the matched route name is provided
   * here. */
  routeName?: string;

  /** Overrides the matched path for future route middleware, when a
   * `routerPath` option is not defined on the `Router` options. */
  routerPath?: string;
}

As for how to resolve error , you can resolve it by giving it types as given in the interface , suppose if you don't want to use type you can just replace it with below code,

{ request, response, state }: RouterContext<string,any,any>,

Goutham J.M
  • 1,726
  • 12
  • 25