8000 Error when i start script with --no-check flag · Issue #97 · cmorten/opine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Error when i start script with --no-check flag #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4ov opened this issue Dec 28, 2020 · 7 comments · Fixed by #99
Closed

Error when i start script with --no-check flag #97

4ov opened this issue Dec 28, 2020 · 7 comments · Fixed by #99
Assignees

Comments

@4ov
Copy link
4ov commented Dec 28, 2020

Issue

Setup:

  • Deno Version: 1.6.2
  • v8 Version: 8.8.278.2
  • Typescript Version: 4.1.3
  • Opine Version: 1.0.0

I'm getting an error while i disable ts check for my app

Details

command : deno run -A --no-check serve.ts
output :

error: Uncaught SyntaxError: The requested module './CtxLike.ts' does not provide an export named 'CtxLike'
export { CtxLike } from "./CtxLike.ts";
~~~~~~~
    at <anonymous> (<https://deno.land/x/evt@v1.9.11/lib/types/interfaces/index.ts>:5:1)

code i use :

import { opine } from "https://deno.land/x/opine@1.0.0/mod.ts";

const app = opine();

app.get("/", function(req, res) {
  res.send("Hello World");
});

app.listen(3000);

@cmorten
Copy link
Owner
cmorten commented Dec 28, 2020

Hi @lowray, thanks for raising this 😄

Having read the Deno manual (REF: https://deno.land/manual@v1.6.2/getting_started/typescript#code--no-checkcode-option) I believe this may be an issue with @garronej's https://github.com/garronej/evt library which Opine uses for it's eventing interface 😢. Namely check out this part of the --no-check docs:

To make the most of skipping type checks, --no-check transpiles each module in isolation without using information from imported modules. This maximizes potential for concurrency and incremental rebuilds. On the other hand, the transpiler cannot know if export { Foo } from "./foo.ts" should be preserved (in case Foo is a value) or removed (in case Foo is strictly a type). To resolve such ambiguities, Deno enforces isolatedModules on all TS code. This means that Foo in the above example must be a value, and the export type syntax must be used instead if Foo is a type.

Which I believe may be the issue as CtxLike which is re-exported in the index.ts file in your error message (REF: https://deno.land/x/evt@v1.9.11/lib/types/interfaces/index.ts#L5) is an interface, not a value, and therefore not found when the --no-check flag is provided.

...
export { CtxLike } from "./CtxLike.ts";
...

I wonder if instead the code should be something like...

/** https://docs.evt.land/api/ctx */
export type Ctx<Result> = import("./Ctx.ts").Ctx<Result>;
export type DoneOrAborted<Result> = import("./Ctx.ts").DoneOrAborted<Result>;
export type CtxLike = import("./CtxLike.ts").CtxLike; // Exported as a type in the same fashion as everything else?
/** 
 * Minimal interface that an object must implement to be a valid context argument 
 * ( for interop between mismatching EVT versions )
 */
export type VoidCtxLike = import("./CtxLike.ts").VoidCtxLike; // Wonder if this line also needs corrected as currently exporting  `CtxLike` as `VoidCtxLike`
export type Evt<T> = import("./Evt.ts").Evt<T>;
...

We can confirm that it is the evt module itself and not Opine through the simple example:

export { Evt } from "https://deno.land/x/evt@v1.9.11/mod.ts";

Which results in...

error: Uncaught SyntaxError: The requested module './CtxLike.ts' does not provide an export named 'CtxLike'
export { CtxLike } from "./CtxLike.ts";
~~~~~~~
    at <anonymous> (<https://deno.land/x/evt@v1.9.11/lib/types/interfaces/index.ts>:5:1)

Would you mind a raising an issue on the https://github.com/garronej/evt repo for the maintainers to fix there?

@4ov
Copy link
Author
4ov commented Dec 28, 2020

I've opened an issue garronej/evt#17
BTW i have another question, have you tried to bundle opine?
I'm getting an error like

error: Uncaught ReferenceError: Cannot access 'request2' before initialization
request2.get = function get(name) {
^

Sorry for the disturbance.

@cmorten
Copy link
Owner
cmorten commented Dec 28, 2020

@lowray no need to apologise! 😄

Are you referring to deno bundle or deno compile? Either way do you mind opening a separate issue with the details so we track this different error there?

Thanks for raising the issue on the evt repo 🙂

@garronej
Copy link
garronej commented Dec 29, 2020

Thanks, @cmorten for doing the investigation work for me!

@garronej
Copy link
garronej commented Dec 29, 2020

@cmorten @lowray DONE. I addressed the issue in v1.9.12 of EVT 🎉.
I would do a PR to update the lock.json but I don't know how you manage it and I am exhausted
Believe it or not, it took me like 5 hours to fix this.
Supporting both older version of typescript and Deno is getting more and more challenging. 😓

@cmorten
Copy link
Owner
cmorten commented Dec 29, 2020

Nice one @garronej, you’re a ⭐️!

Gosh that does sounds exhausting 😞

I’ll get things sorted from this end

@cmorten cmorten self-assigned this Dec 29, 2020
8000
cmorten added a commit that referenced this issue Dec 29, 2020
@4ov
Copy link
Author
4ov commented Dec 29, 2020

@garronej @cmorten i really appreciate it.
thank you all ♥️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0