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.

Stack overflow on certain platforms

See original GitHub issue

From @h-joo at https://github.com/microsoft/TypeScript/issues/45571

type SomeType = number | string | SomeType[];

declare var obj: { key: SomeType; };

declare namespace jasmine {
    interface Matchers<T> {
        toEqual(expected: Expected<T>): void;
    }

    type Expected<T> = T | {
        [K in keyof T]: ExpectedRecursive<T[K]>;
    }

    type ExpectedRecursive<T> = T | {
        [K in keyof T]: ExpectedRecursive<T[K]>;
    };
}

declare function expect<T>(actual: T): jasmine.Matchers<T>;

expect(obj).toEqual({ key: 'value1' });

With tsc or in the editor

> tsc -p src
src/index.ts:19:21 - error TS2589: Type instantiation is excessively deep and possibly infinite.

expect(obj).toEqual({key: 'value1'});
                    ~~~~~~~~~~~~~~~

Or in the playground for me:

simpleWorker.ts:125 Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at isTypeAssignableTo (tsWorker.js:60285)
    at isApplicableIndexType (tsWorker.js:56207)
    at findApplicableIndexInfo (tsWorker.js:56187)
    at getApplicableIndexInfo (tsWorker.js:56236)
    at getPropertyTypeForIndexType (tsWorker.js:58675)
    at getIndexedAccessTypeOrUndefined (tsWorker.js:59018)
    at getIndexedAccessType (tsWorker.js:58940)
    at instantiateTypeWorker (tsWorker.js:60141)
    at instantiateTypeWithAlias (tsWorker.js:60092)
    at instantiateType (tsWorker.js:60075)

This seems to have been caused by the newly introduced recursive definition of the IDBValidKey, and this causes an infinite type instantiation.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
DanielRosenwassercommented, Aug 25, 2021

Hm - there’s a few things to note I think.

  1. The “deep or possibly infinite” error is probably not desirable, but maybe the best we can do here, so I guess that’s expected.
  2. The fact that IDBValidKey changed was part of what triggered the investigation. The definition of IDBValidKey seems correct, so the fact that this type doesn’t play well with Jasmine might be a pill we have to swallow for 4.4.
  3. The stack overflow does seems like a problem. I see it in Edge, but not in Firefox or Node.
0reactions
charlescappscommented, Dec 10, 2021

I just verified I don’t get this Maximum call stack size exceeded error on version 4.5.2 of typescript, so this is likely a regression in the current latest release - 4.5.3 at time of writing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What community platform/software is Stack Overflow built on?
Stack Overflow is the worlds largest community of software developers. Software developers are in crazy high demand - and most already have jobs....
Read more >
Stack Overflow - Where Developers Learn, Share, & Build ...
A private collaboration & knowledge sharing SaaS platform for companies. A web-based platform to increase productivity, decrease cycle times, accelerate time to ...
Read more >
All Sites - Stack Exchange
We make Stack Overflow and 170+ other community-powered Q&A sites. ... Stack Overflow. Stack Overflow. Q&A for professional and ... Meta Stack Exchange....
Read more >
Stack Overflow for Teams
Stack Overflow for Teams is a secure knowledge sharing platform trusted by the world's largest community of developers and technologists.
Read more >
Stack Overflow - Wikipedia
The website serves as a platform for users to ask and answer questions, and, through membership and active participation, to vote questions 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