Stack overflow on certain platforms
See original GitHub issueFrom @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:
- Created 2 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hm - there’s a few things to note I think.
IDBValidKey
changed was part of what triggered the investigation. The definition ofIDBValidKey
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.I just verified I don’t get this
Maximum call stack size exceeded
error on version4.5.2
oftypescript
, so this is likely a regression in the current latest release -4.5.3
at time of writing.