vedantroy/typecheck.macro

TSIndexedAccessType unexpected error

aynik opened this issue · 2 comments

aynik commented

I have an autogenerated type (by graphql codegen) like this:

/** Specifies the fields required to create a new customer. */
export type CustomerCreateInput = {
  /** The customer’s first name. */
  readonly firstName?: Maybe<Scalars['String']>
  /** The customer’s last name. */
  readonly lastName?: Maybe<Scalars['String']>
  /** The customer’s email. */
  readonly email: Scalars['String']
  /**
   * A unique phone number for the customer.
   *
   * Formatted using E.164 standard. For example, _+16135551111_.
   */
  readonly phone?: Maybe<Scalars['String']>
  /** The login password used by the customer. */
  readonly password: Scalars['String']
  /** Indicates whether the customer has consented to be sent marketing material via email. */
  readonly acceptsMarketing?: Maybe<Scalars['Boolean']>
}

Then in the same file I add:

registerType('CustomerCreateInput')
export const isValidCustomerCreateInput = createValidator<CustomerCreateInput>()

And my app throws an error like this:

./models/shopify.ts
MacroError: <rootDir>/models/shopify.ts: Unexpected error because TSIndexedAccessType was not expected. Please report this to the developer.

Let me know if you need more information, and thanks for this library!

What is Scalars? Is it a type in the same file? Can you post the Scalars type?

aynik commented

What is Scalars? Is it a type in the same file? Can you post the Scalars type?

Sure, here it is:

export type Scalars = {
  ID: string;
  String: string;
  Boolean: boolean;
  Int: number;
  Float: number;
  /** An ISO-8601 encoded UTC date time string. Example value: `"2019-07-03T20:47:55Z"`. */
  DateTime: any;
  /** A signed decimal number, which supports arbitrary precision and is serialized as a string. Example value: `"29.99"`. */
  Decimal: any;
  /** A string containing HTML code. Example value: `"<p>Grey cotton knit sweater.</p>"`. */
  HTML: any;
  /** A monetary value string. Example value: `"100.57"`. */
  Money: any;
  /**
   * An RFC 3986 and RFC 3987 compliant URI string.
   *
   * Example value: `"https://johns-apparel.myshopify.com"`.
   *
   */
  URL: any;
};