lukeed / ley

(WIP) Driver-agnostic database migrations
MIT License
259 stars 14 forks source link

Typescript error #20

Closed dervaux closed 2 years ago

dervaux commented 3 years ago

Dear @lukeed, I've been trying to implement ley with Typescript. After following your documentation and implementing this issue's solution: https://github.com/lukeed/ley/issues/13, I'm still getting this ts error message:

Screenshot 2021-06-24 at 18 16 36

'1624547133-create-users-table.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.ts(1208) var exports: any Any idea about what could be missing here?

jgod commented 2 years ago

Don't use module.exports. prepend your function declaration with export instead. export async function up(sql) {

lukeed commented 2 years ago

Yes, @jgod is correct here. I'm just noticing that the readme is missing a full TS example, sorry about that. Your snippet should look like this:

import { Client } from 'postgres';

export async function up(sql: Client) {
  await sql`...`;
}

And sorry about the delay, I don't know how/why I missed this for so long 😕