Skip to content
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

Issue when using esModuleInterop option #119

Open
tsiege opened this issue Jun 16, 2020 · 3 comments
Open

Issue when using esModuleInterop option #119

tsiege opened this issue Jun 16, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@tsiege
Copy link
Contributor

tsiege commented Jun 16, 2020

I'm running into an issue with the orderBy statement on a query. Fairly certain this is a bug with the type definitions since the code works correctly and is cribbed from the examples. I've looked for an enum to no avail, but I don't think I should need it since the definition uses a Union type called OrderByDirection.

The following code results in this error

        return client.models.Post.findMany()
          .orderBy([{ publishedAt: 'DESC' }])
          .resolveInfo(info)
          .execute()
Type 'string' is not assignable to type '("ASC" & { [x: string]: "ASC" | "DESC" | undefined; }) | ("ASC" & { sum?: { [x: string]: "ASC" | "DESC" | undefined; } | undefined; avg?: { [x: string]: "ASC" | "DESC" | undefined; } | undefined; min?: { ...; } | undefined; max?: { ...; } | undefined; } & { ...; }) | ("DESC" & { ...; }) | ("DESC" & ... 1 more ... & ...'.
@danielrearden
Copy link
Owner

@tsiege Thanks for the bug report. This does appear to be an issue with the type definitions, but I'm not able to reproduce it on my end. Do you think you could put together a gist or repo with the code needed to reproduce it?

@danielrearden danielrearden added the bug Something isn't working label Jun 16, 2020
@tsiege
Copy link
Contributor Author

tsiege commented Jun 16, 2020

@danielrearden I was able to scope it down to an issue with my tsconfig. Having "esModuleInterop": true, causes the issue, which is surprising since your target output for sqlMancer is commonjs. I wonder if it might be an issue with typescript. I'm on TS version^3.9.5

Here's my tsconfig. If that's not enough I can share a dummy repo

{
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "build",
    "removeComments": true,
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "allowJs": true,
    "importHelpers": true,
    "alwaysStrict": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "strictNullChecks": false
  },
  "include": [
    "migrations/**/*",
    "scripts/**/*",
    "src/**/*",
  ]
}

@danielrearden
Copy link
Owner

Thanks, that's super helpful. I'll investigate what can be done on this side to prevent those sort of errors.

@danielrearden danielrearden changed the title Trouble with OrderBy Issue when using esModuleInterop option Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants