adriatic / TypeScript-problem

This repository is created solely to define the problem as issue 1
0 stars 0 forks source link

TypeScript problem in graphql.d.ts #1

Open adriatic opened 2 years ago

adriatic commented 2 years ago

I reported this https://github.com/redwoodjs/redwood/issues/6078 issue, discovered in the context of trying to create a TypeScript version of the Redwood Tutorial. At that time I was not aware of the same effort by @rushabhhere. As I was having the similar issue with a different application (redwood-stripe) I decided to convert the redwood tutorial app to typescript hoping to better understand my original problem, described below


In order to reproduce my issue create any TypeScript app

yarn create redwood-app --ts ./myapp

Observe the just generated file graphql.d.ts in api/types folder, the definition of the scalars type

/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
  ID: string;
  String: string;
  Boolean: boolean;
  Int: number;
  Float: number;
  BigInt: number;
  Date: string;
  DateTime: string;
  JSON: Prisma.JsonValue;
  JSONObject: Prisma.JsonObject;
  Time: string;
};

This same code rendered by VSCode is:

image

The issue with JSON and JSONObject is

image

Seemingly an import statement is missing 😺

Tobbe commented 2 years ago

Yeah, this is not a problem with any particular RW project. If we should/could fix it, it'd be in the framework code for type generation. I'm not sure what change needs to be made though. If you could dig into it and find a solution that'd be awesome :)

adriatic commented 2 years ago

@Tobbe - I believe that I did find the change and it is trivial - please check my explanation to @rushabhhere (https://github.com/rushabhhere) so I do not pollute all discussions with my comments 😸 .