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.

Error: Excessive stack depth comparing types 'ParseMixedSchema<?, T>' and 'ParseMixedSchema<?, T>'.ts(2321)

See original GitHub issue

As of version 1.6.5, I now get this error in several places in my code.

Excessive stack depth comparing types 'ParseMixedSchema<?, T>' and 'ParseMixedSchema<?, T>'.ts(2321)

It comes from this:

import type { FromSchema } from 'json-schema-to-ts';
import createHttpError, { NamedConstructors } from 'http-errors';
import { URLSearchParams } from 'url';

export type ValidatedAPIGatewayProxyEvent<S> = APIGatewayProxyEvent &
  FromSchema<S>;

which I adopted from the Serverless Framework TS template.

I create a JS/JSON API Gateway schema, e.g.:

const schema = {
  type: 'object',
  properties: {
    body: {
      type: 'object',
      properties: {
        coupon_id: { type: 'string' },
        end_of_term: { type: 'boolean' },
        plan_id: { type: 'string' },
        subscription_id: { type: 'string' },
        reactivate: { type: 'boolean' },
        first_payment: { type: 'boolean' },
      },
      required: ['end_of_term', 'plan_id', 'subscription_id'],
      additionalProperties: false,
    },
  },
} as const;

and pass it to Sentry’s wrapHandler:

export const handler = Sentry.AWSLambda.wrapHandler<
      ValidatedAPIGatewayProxyEvent<S>,
      APIGatewayProxyResult | undefined
    >(...

This has worked fine up until the latest release.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dafflcommented, Jan 25, 2022

I’ve been seein the same error in the latest version in https://github.com/feathersjs/feathers/tree/dove/packages/schema. The smallest example I could come up with to reproduce looks like this:

class Test<S extends JSONSchema> {
  readonly type: FromSchema<S>;
}

const schemaA = {
  type: 'object',
  additionalProperties: false,
  properties: {
    name: { type: 'string' }
  }
} as const;

const schemaB = {
  type: 'object',
  additionalProperties: false,
  properties: {
    name: { type: 'string' }
  }
} as const;

const t: Test<typeof schemaB> = new Test<typeof schemaA>();

Maybe that helps, I can try and do some more digging if you think it’s worth investigating. Either way, this is a great project!

0reactions
ericvicenticommented, Aug 17, 2022

I think this can be closed. I haven’t seen this weirdo error in a while

Now I just need to find workarounds for “Type instantiation is excessively deep and possibly infinite” 😤

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excessive stack depth comparing types 'Snapshot<T>' and ...
The error occurs because the return type of the child method in the firebase.database.DataSnapshot is that of its enclosing interface.
Read more >
type-graphql/Lobby - Gitter
Hard to say, it doesn't look like a TypeGraphQL fault ... and this is blocked by the [at-loader] TS2321: Excessive stack depth comparing...
Read more >
Developers - TS2321: Excessive stack depth comparing types ...
Steps to reproduce or a small repository showing the problem: I am trying to build an API with typeorm and type-graphql. The following...
Read more >
Typescript rendering via map error: Excessive stack depth ...
Coding example for the question Typescript rendering via map error: Excessive stack depth comparing types-Reactjs.
Read more >
[REQ] Python clientlib should have type annotations - OpenAPITools ...
The python ecosystem as a whole is moving towards type annotations being ... Error: Excessive stack depth comparing types 'ParseMixedSchema<?, T>' and ...
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