Skip to content

Maximum call stack size exceeded #14723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cri5ti opened this issue Mar 18, 2017 · 2 comments
Closed

Maximum call stack size exceeded #14723

cri5ti opened this issue Mar 18, 2017 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@cri5ti
Copy link

cri5ti commented Mar 18, 2017

TypeScript Version: 2.2.1 / nightly 2.3.0-dev.20170318

The smallest code I got that produces the issue is:

class Component<S> {
    setState<K extends keyof S>(state: Pick<S, K>) {}
}

export interface State<T> {
    a?: T;
}

class Foo {}

class Comp<T extends Foo, S> extends Component<S & State<T>>
{
    foo() {
        const a:T = {};
        this.setState({ a: a });
    }
}

Throws:

RangeError: Maximum call stack size exceeded
    at getConstraintFromTypeParameter (D:\...\node_modules\typescript\lib\tsc.js:24863:48)
    at getConstraintOfTypeParameter (D:\...node_modules\typescript\lib\tsc.js:24268:66)
    at isRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26681:42)
    at isRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26665:38)
    at typeArgumentsRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26904:35)
    at isRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26706:38)
    at isRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26688:42)
    at isRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26665:38)
    at typeArgumentsRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26904:35)
    at isRelatedTo (D:\...\node_modules\typescript\lib\tsc.js:26706:38)

No configuration required.
Windows / Node 7.7.3

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Mar 19, 2017
@mhegazy mhegazy added this to the TypeScript 2.3 milestone Mar 20, 2017
@jamesknelson
Copy link

jamesknelson commented Mar 21, 2017

Think I've got a similar issue, based on the stack trace. I've managed to get the offending code down to this:

type Attributes<Keys extends string> = {
    [Key in Keys]: string; // I'm actually using Attribute<Key> in my code, but `string` is all that is needed to cause the RangeError
}

class Query<A extends Attributes<keyof A>> {
    multiply<B extends Attributes<keyof B>>(x: B): Query<A & B>;
}

Stack trace:

/usr/local/lib/node_modules/typescript/lib/tsc.js:51296
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26081:33)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26166:38)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26139:42)
    at typeRelatedToEachType (/usr/local/lib/node_modules/typescript/lib/tsc.js:26351:35)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26125:34)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26189:42)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26147:38)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26153:38)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26153:38)
    at isRelatedTo (/usr/local/lib/node_modules/typescript/lib/tsc.js:26153:38)

I'm on tsc 2.2.1, node 7.7.2, osx 10.11.6

@ahejlsberg
Copy link
Member

@jamesknelson The issue you're seeing above isn't related to this one (and isn't fixed by #14874). Would you mind creating a new issue.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 28, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

6 participants