question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript examples don't compile with `tsc`

See original GitHub issue

Currently, the typescript/graphql-auth example works when following the instructions from the README:

npm install
npm run dev

This starts the server as expected and you can send queries to it.

However, when compiling with tsc, it fails:

$ npx tsc
src/types/Mutation.ts:70:13 - error TS2322: Type '{ connect: { id: string | undefined; }; }' is not assignable to type 'UserCreateOneWithoutPostsInput'.
  The types of 'connect.id' are incompatible between these types.
    Type 'string | undefined' is not assignable to type 'number | null | undefined'.
      Type 'string' is not assignable to type 'number | null | undefined'.

70             author: { connect: { id: userId } },
               ~~~~~~

  node_modules/@prisma/client/index.d.ts:2558:3
    2558   author?: UserCreateOneWithoutPostsInput | null
           ~~~~~~
    The expected type comes from property 'author' which is declared here on type 'PostCreateInput'

src/types/Mutation.ts:83:13 - error TS2322: Type 'string | null | undefined' is not assignable to type 'number | null | undefined'.
  Type 'string' is not assignable to type 'number | null | undefined'.

83             id,
               ~~

  node_modules/@prisma/client/index.d.ts:2535:3
    2535   id?: number | null
           ~~
    The expected type comes from property 'id' which is declared here on type 'PostWhereUniqueInput'

src/types/Mutation.ts:95:20 - error TS2322: Type 'string | null | undefined' is not assignable to type 'number | null | undefined'.
  Type 'string' is not assignable to type 'number | null | undefined'.

95           where: { id },
                      ~~

  node_modules/@prisma/client/index.d.ts:2535:3
    2535   id?: number | null
           ~~
    The expected type comes from property 'id' which is declared here on type 'PostWhereUniqueInput'


Found 3 errors.

We should:

  • check whether this happens also for other TS examples
  • fix the errors in typescript/graphql-auth and any others we find

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nikolasburkcommented, Feb 26, 2020

This also happens in typescript/graphql-sdl-first

Yeah, it probably happens in most TS examples I could imagine since we never tested for that…

0reactions
steebchencommented, Jun 13, 2020

@ngduc Please open a new issue and describe in which repository this happens exactly. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - tsc CLI Options - TypeScript
Flag Type Default ‑‑allowJs boolean false ‑‑allowUmdGlobalAccess boolean false ‑‑allowUnreachableCode boolean
Read more >
typescript compiler (tsc) command not working with tsconfig
and I run tsc on command prompt, but it won't work and outputs me the syntax, example and options of how to use...
Read more >
TypeScript Compiling with Visual Studio Code
Under the covers, we run the TypeScript compiler as a task. The command we use is: tsc -p . Step 3: Make the...
Read more >
Getting Started With TypeScript Compiler (tsc) - maxoid.io
Don't focus on the code too much. It's just an example of TypeScript code but first of all, we need to focus on...
Read more >
Do not perform typechecking if files are unchanged ... - GitHub
We call tsc with pinned versions of both Node and TypeScript and point it to the tsconfig.json file with the -p compiler flag....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found