middleware icon indicating copy to clipboard operation
middleware copied to clipboard

isolatedModule and responseTypeHeader error while running the sample code

Open borsemayur2 opened this issue 3 years ago • 1 comments

Code:

import { Application } from "https://deno.land/x/oak/mod.ts";

import { responseTimeHeader } from "https://deno.land/x/oak_middleware/observability/response_time_header.ts";
const app = new Application();

app.use(responseTimeHeader);

app.use((ctx: any, next: any) => {
  ctx.response.body = "Hello Oak!";
});
console.log("listening on port 8080");
app.listen({ port: 8080 });

I'm getting following errors:

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

TS2724 [ERROR]: '"https://deno.land/x/[email protected]/observability/response_time_header.ts"' has no exported member named 'responseTimeHeader'. Did you mean 'responseTypeHeader'?
import { responseTimeHeader } from "https://deno.land/x/oak_middleware/observability/response_time_header.ts";

   'responseTypeHeader' is declared here.
    export const responseTypeHeader: Middleware = async function (ctx, next) {
                 ~~~~~~~~~~~~~~~~~~
        at https://deno.land/x/[email protected]/observability/response_time_header.ts:22:14

The code at deno.land still points to responseTypeHeader. This seems the issue for responseTypeHeader error. image

borsemayur2 avatar Apr 15 '21 01:04 borsemayur2

github code version

import {responseTimeHeader} from "https://raw.githubusercontent.com/oakserver/middleware/main/observability/response_time_header.ts"

errors:

TS2345 [ERROR]: Argument of type 'import("https://deno.land/x/[email protected]/middleware.ts").Middleware<Record<string, any>, import("https://deno.land/x/[email protected]/context.ts").Context<Record<string, any>>>' is not assignable to parameter of type 'import("https://deno.land/x/[email protected]/middleware.ts").Middleware<Record<string, any>, import("https://deno.land/x/[email protected]/context.ts").Context<Record<string, any>>>'.
  Types of parameters 'context' and 'context' are incompatible.
    Type 'import("https://deno.land/x/[email protected]/context.ts").Context<Record<string, any>>' is not assignable to type 'import("https://deno.land/x/[email protected]/context.ts").Context<Record<string, any>>'.
      Types of property 'app' are incompatible.
        Type 'Application<State>' is not assignable to type 'Application<any>'.
          Property '#middleware' in type 'Application' refers to a different member that cannot be accessed from within type 'Application'.
app.use(responseTimeHeader);
        ~~~~~~~~~~~~~~~~~~

borsemayur2 avatar Apr 15 '21 02:04 borsemayur2