crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Typo in postgraphile/examples/servers/koa/vanilla.ts

Open vibl opened this issue 3 years ago • 5 comments

https://github.com/graphile/postgraphile/blob/7d2906c1c23d29f7ad4932779aaccb8604e065e3/examples/servers/koa/vanilla.ts#L2

vibl avatar Jul 30 '22 10:07 vibl

Please could you detail what the typo is? I don't see it.

benjie avatar Jul 30 '22 11:07 benjie

My bad: I didn't know this syntax existed.

I just found the reference: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require (in case anyone else is confused).

Sorry for the false alert!

vibl avatar Jul 30 '22 11:07 vibl

BTW, I get the following error in VSCode for this line:

Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.ts(1202)

vibl avatar Jul 30 '22 11:07 vibl

I reopen this issue in case someone has a suggestion about the Typescript error.

vibl avatar Jul 30 '22 11:07 vibl

It's a painful time right now for ESM versus CommonJS. The example assumes you're compiling down to CommonJS, with ESM you can't use require (why?!) so either replace it with a proper import statement or await import('...') somewhere.

benjie avatar Jul 30 '22 11:07 benjie