Skip to content
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

TSLint RangeError: Maximum call stack size exceeded #1288

Closed
patrickhousley opened this issue Jan 4, 2017 · 6 comments
Closed

TSLint RangeError: Maximum call stack size exceeded #1288

patrickhousley opened this issue Jan 4, 2017 · 6 comments
Labels
guidance Question that needs advice or information.

Comments

@patrickhousley
Copy link

I am getting the below error when running tslint.

RangeError: Maximum call stack size exceeded
    at resolveAlias (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25256:22)
    at /Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25705:58
    at Object.forEachProperty (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:1966:26)
    at getAccessibleSymbolChainFromSymbolTable (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25698:27)
    at /Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25711:97
    at Object.forEachProperty (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:1966:26)
    at getAccessibleSymbolChainFromSymbolTable (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25698:27)
    at /Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25711:97
    at Object.forEachProperty (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:1966:26)
    at getAccessibleSymbolChainFromSymbolTable (/Users/patrickhousley/Documents/projects/lambda-functions/node_modules/typescript/lib/typescript.js:25698:27)

TSLint Configuration:

{
  "rules": {
    "max-line-length": [true, 999],
    "no-string-literal": false,
    "ordered-imports": false,
    "no-unused-variable": true,
    "no-use-before-declare": true,
    "variable-name": [
      true,
      "ban-keywords",
      "check-format",
      "allow-leading-underscore"
    ]
  }
}

Example lambda function:

import * as CognitoIdentity from 'aws-sdk/clients/cognitoidentity';

const cognitoIdentity = new CognitoIdentity();

export class Test {

  constructor() {
    this.test();
  }

  private test(): Promise<CognitoIdentity.Types.GetOpenIdTokenForDeveloperIdentityResponse> {
    return new Promise((resolve, reject) => {
      const params: CognitoIdentity.Types.GetOpenIdTokenForDeveloperIdentityInput = {
        IdentityPoolId: 'test',
        Logins: {
          test: 'test'
        },
        TokenDuration: 1800
      };

      cognitoIdentity.getOpenIdTokenForDeveloperIdentity(params, (error: Error, data: CognitoIdentity.Types.GetOpenIdTokenForDeveloperIdentityResponse) => {
        if (error) {
          reject(error);
          return;
        } else if (!data || !data.IdentityId || !data.Token) {
          reject(new Error('Cognito did not respond with a valid token or identity id'));
          return;
        }

        resolve(data);
      });
    });
  }

}

I can bypass the issue if I remove the rules no-unused-variable and no-use-before-declare or if I just import the entire sdk like import * as AWS from 'aws-sdk';. I should also note that the code builds just fine using Webpack and all my tests function fine.

My goal is to import only the clients from the SDK that I need. My full lambda function built with Webpack 2 and tree shaking is ~378kB if I just import the clients I need but it pushes 1.65MB if I import the entire SDK.

@chrisradek
Copy link
Contributor

@patrickhousley
Can you share how you're running tslint? I created a new project using your exact samples/config, and am not seeing the same tslint error you reported. tslint did warn about no-unused-variable being deprecated, but that was the only message I received.

I ran tslint on the single file, using 4.2.0 of tslint and 2.1.4 of the typescript compiler.

@patrickhousley
Copy link
Author

Relevant package.json entry:

"lint": "tslint --type-check --project tsconfig.json -e './src/**/*.spec.ts' './src/**/*'",

@patrickhousley
Copy link
Author

@chrisradek I will try to setup a sample project later today to help troubleshooting.

@patrickhousley
Copy link
Author

@chrisradek Sorry it took so long. I setup a repo to reproduce the error: https://github.com/patrickhousley/aws-sdk-tslint-range-error

@patrickhousley
Copy link
Author

This issue has been fixed per microsoft/TypeScript#12808

@srchase srchase added guidance Question that needs advice or information. and removed Question labels Jan 4, 2019
@lock
Copy link

lock bot commented Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants