Repository: TypeScript
Issue: Stack overflow in long concatenating string
Labels: Bug,Crash

<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!

Please help us by doing the following steps before logging an issue:
  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues
  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ

Please fill in the *entire* template below.
-->

<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
**TypeScript Version:**  3.2.0-dev.20181011

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**
stack overflow, long string

**Code**

Following link has complete failing example,
https://gist.github.com/ackava/673d9fc93cb4b48c4a1b3b4aff807c2f#file-akashdataurl-stack-overflow-ts

This is data url generated from an image, which contains base64 representation in concatenating strings.

```ts
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

const base64 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + 
       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + 
       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
       .... 800 more lines with exact same length
       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
```

**Expected behavior:**
It should compile as it is a valid javascript.

**Actual behavior:**
It ends up in stack overflow.

```
PS D:\Temp\ts-bug> npm install -s typescript@next
+ typescript@3.2.0-dev.20181011
added 1 package in 3.028s
PS D:\Temp\ts-bug> .\node_modules\.bin\tsc
D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:69654
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at needsIndentation (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:67933:34)
    at emitBinaryExpression (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:66629:40)
    at pipelineEmitWithHint (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:66043:32)
    at emitNodeWithSourceMap (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:64787:24)
    at pipelineEmitWithSourceMap (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:65746:58)
    at emitNodeWithNestedComments (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:65097:17)
    at emitNodeWithSynthesizedComments (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:65047:13)
    at emitNodeWithComments (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:65020:21)
    at pipelineEmitWithComments (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:65738:13)
    at emitNodeWithNotification (D:\Temp\ts-bug\node_modules\typescript\lib\tsc.js:64500:21)
PS D:\Temp\ts-bug>
```

I did find an alternative, this one works correctly where strings are represented as an array and then I join in the end. Following file works correctly.
https://gist.github.com/ackava/673d9fc93cb4b48c4a1b3b4aff807c2f#file-akashdataurl-working-array-ts


**Playground Link:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior -->

**Related Issues:** <!-- Did you find other bugs that looked similar? -->