Skip to content

typescript crashes when parsing certain invalid tsconfig files, instead of giving a useful error messages #26076

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
dgoldstein0 opened this issue Jul 31, 2018 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@dgoldstein0
Copy link

dgoldstein0 commented Jul 31, 2018

TypeScript Version: 3.0.1 and 2.7.2 both repro. I suspect this bug is rather old as the custom json parser was introduced in 1.8.

Search Terms:

Code

tsconfig.json:

{
  "compilerOptions": {
    ## this comment does cause issues
    "types" : [
    ]
  }
}

and then tsc --project tsconfig.json

Expected behavior:

I expect typescript to tell me what about my tsconfig file is invalid

Actual behavior:

I get a mostly unhelpful stack trace:

/home/dgoldstein/node_modules/typescript/lib/tsc.js:9382
        return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
                  ^

TypeError: Cannot read property 'length' of undefined
    at Object.unescapeLeadingUnderscores (/home/dgoldstein/node_modules/typescript/lib/tsc.js:9382:19)
    at convertObjectLiteralExpressionToJson (/home/dgoldstein/node_modules/typescript/lib/tsc.js:18925:34)
    at convertPropertyValueToJson (/home/dgoldstein/node_modules/typescript/lib/tsc.js:18997:32)
    at convertObjectLiteralExpressionToJson (/home/dgoldstein/node_modules/typescript/lib/tsc.js:18930:29)
    at convertPropertyValueToJson (/home/dgoldstein/node_modules/typescript/lib/tsc.js:18997:32)
    at convertToObjectWorker (/home/dgoldstein/node_modules/typescript/lib/tsc.js:18907:16)
    at parseOwnConfigOfJsonSourceFile (/home/dgoldstein/node_modules/typescript/lib/tsc.js:19396:20)
    at parseConfig (/home/dgoldstein/node_modules/typescript/lib/tsc.js:19318:13)
    at parseJsonConfigFileContentWorker (/home/dgoldstein/node_modules/typescript/lib/tsc.js:19204:28)
    at parseJsonSourceFileConfigFileContent (/home/dgoldstein/node_modules/typescript/lib/tsc.js:19183:16)

Related Issues: didn't see any

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 31, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 31, 2018
sheetalkamat added a commit that referenced this issue Aug 1, 2018
@sheetalkamat sheetalkamat added the Fixed A PR has been merged for this issue label Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants