cmorten / superoak

HTTP assertions for Oak made easy via SuperDeno. 🐿 🦕
https://cmorten.github.io/superoak/
MIT License
121 stars 8 forks source link

Project does not compile with latest version of oak using Deno 1.3.0 #20

Closed kamiranoff closed 3 years ago

kamiranoff commented 3 years ago

Issue

Project not compiling using oak

Setup: macOS Big Sur deno 1.3.0 v8 8.6.334 typescript 3.9.7

Details

Not sure exactly why but my project is not compiling with the latest version of superoak and oak

Here is a reproducible case:

deps.ts

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

export { superoak } from "https://deno.land/x/superoak/mod.ts";

app.ts

import { Application, Router } from './deps.ts';

const router = new Router();
router
  .get('/', (context) => {
    context.response.body = 'Hello 👋';
  })

const app = new Application();

export { app };
app.use(router.routes());

await app.listen({ port: 8080 });

I am running

/usr/local/bin/den ./app.ts
cmorten commented 3 years ago

Hey @kamiranoff 👋

Sorry for the slow reply - will try and take a look soon! When you say compile, do you mean just use den ( as in your provided example ) or using deno compile?

Is there a particular error you are seeing in the console?

As an aside recommendation, unless you are using superoak in your application I would recommend splitting it out into a separate test deps file - deno imports don’t provide any treeshaking afaik, so superoak will be shipped with your app, which especially in the case of creating 3rd party libs adds unnecessary bloat ( though given the example, assume you’re potentially not creating a shareable lib! ).

kamiranoff commented 3 years ago

Hi @cmorten !

Sorry, I am not too familiar with deno.

I think I made a typo, that is what I am running:

/usr/local/bin/deno run /Users/kamiranoff/dev/projects/deno-test/app.ts

And the console output shows a lot of TypeScript issues. Here is the first few lines:

/usr/local/bin/deno run /Users/kamiranoff/dev/projects/deno-test/app.ts
Check file:///Users/kamiranoff/dev/projects/deno-test/app.ts
error: TS2552 [ERROR]: Cannot find name 'global'. Did you mean '_global'?
var _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
                                                                                                    ~~~~~~
    at https://jspm.dev/npm:component-emitter@1.3.0!cjs:1:101

    '_global' is declared here.
    var _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
        ~~~~~~~
        at https://jspm.dev/npm:component-emitter@1.3.0!cjs:1:5

TS7006 [ERROR]: Parameter 'obj' implicitly has an 'any' type.
function Emitter(obj) {
                 ~~~
    at https://jspm.dev/npm:component-emitter@1.3.0!cjs:15:18

TS7006 [ERROR]: Parameter 'obj' implicitly has an 'any' type.
function mixin(obj) {
               ~~~
    at https://jspm.dev/npm:component-emitter@1.3.0!cjs:28:16

Thanks for the recommendation, and thank you for the open-source work!

cmorten commented 3 years ago

Hey @kamiranoff, so I can confirm for the example you provided that we see errors with Deno 1.3.0 ( which you listed in the provided information ).

https://user-images.githubusercontent.com/11313985/107891197-e2cc4900-6f14-11eb-8e95-d70eb5c6a60e.mov

Unfortunately in this first major version of Deno there have been quite a number of breaking changes across minor versions which could explain the issue ( it could be something else also ). I would recommend upgrading to the latest minor version of deno using deno upgrade ( at the time of writing, this is 1.7.4 ), which I've tested with your example and can confirm works for me on MacOS Mojave:

https://user-images.githubusercontent.com/11313985/107891316-b9f88380-6f15-11eb-8d97-79f36ce8fce8.mov

Can you give that a go and see if it resolves your issues?

kamiranoff commented 3 years ago

@cmorten yes, I can confirm it runs fine with Deno 1.7.4. I guess, supporting Deno 1.3.0, is not really a necessity. Let me know if you want me to close the issue. Thanks for the investigation!

cmorten commented 3 years ago

@kamiranoff for the time being I’m not looking to guarantee back compatibility with all minor versions, as there are in the 1.2.x and 1.3.x range for which that task is near impossible ( due to breaking changes in Deno / the standard library ).

I endeavour to keep the version which CI is running against and I provide support for in the version.ts - this isn’t very visible though, so what I’ll do is raise a PR to make use of a badge that I’ve seen circulating which states the supported deno version range in the readme 😊 hopefully that will help others in future!

lucacasonato commented 3 years ago

@cmorten I suggest drop support for everything before 1.5. Breakage since then has been minimal.

cmorten commented 3 years ago

Added the version support to the readme —> 4d67a5d1067b5ec679656ed9ad0888a045fb3a62