Coder Social home page Coder Social logo

error: TS2345 [ERROR]: Argument of type 'Application<Record<string, any>>' is not assignable to parameter of type 'string | Application<Record<string, any>>'. about superoak HOT 4 CLOSED

cmorten avatar cmorten commented on June 14, 2024
error: TS2345 [ERROR]: Argument of type 'Application>' is not assignable to parameter of type 'string | Application>'.

from superoak.

Comments (4)

Leonardo-Rocha avatar Leonardo-Rocha commented on June 14, 2024 2

@asos-craigmorten
It looks like it's working now. Thanks Craig!

from superoak.

asos-craigmorten avatar asos-craigmorten commented on June 14, 2024

@Leonardo-Rocha can you confirm the version/branch/commit you are using in your app to import Oak?

I'm guessing I might have coupled SuperOak too tightly to a specific Oak version (v5.0.0) which is destined to fail as Oak progresses (without a lot of work) and would not be scalable for backwards compatibility - I'll look to loosen the types this morning and get a patch out.

from superoak.

asos-craigmorten avatar asos-craigmorten commented on June 14, 2024

I can confirm the issue exists and reproduced with:

import { Router, Application } from "https://deno.land/x/oak@master/mod.ts";
import { superoak, SuperDeno } from "https://deno.land/x/superoak@master/mod.ts";

const router = new Router();
const app = new Application();

router.get("/", (ctx) => {
  ctx.response.body = "Hello Deno!";
});

app.use(router.routes());
app.use(router.allowedMethods());

const request: SuperDeno = await superoak(app);

request.get("/").end((err) => {
  if (err) throw err;
});

With error:

error: TS2345 [ERROR]: Argument of type 'Application<Record<string, any>>' is not assignable to parameter of type 'string | Application<Record<string, any>>'.
  Type 'import("https://deno.land/x/oak@master/application").Application<Record<string, any>>' is not assignable to type 'import("https://deno.land/x/[email protected]/application").Application<Record<string, any>>'.
    Property '#middleware' in type 'Application' refers to a different member that cannot be accessed from within type 'Application'.
const request: SuperDeno = await superoak(app);

from superoak.

asos-craigmorten avatar asos-craigmorten commented on June 14, 2024

Fixed in #2

Have re-tested with above snippet and works as expected. Please re-open if the issue persists.

Note: you will need to update to 1.0.1 of SuperOak, or if you are using master for versioning your import, you may need to pass a --reload flag to pull down the latest and break the existing Deno cache.

from superoak.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.