Repository: TypeScript
Issue: [RFC] Towards an Intelligent and Interactive TypeScript
Labels: Suggestion,In Discussion,Domain: Error Messages

# Background

One of the biggest problems for newcomers is how unapproachable build tools can be. Users often have to deal with rough compiler messages and are faced day-to-day with with harsh statements like "token expected", "no files specified", or "this isn't really what you grew up wanting to do".

People need to be treated like people. This is our fundamental mantra. We must reject the cold mechanical grips of today's build tools, and build humane build tools for humans. For this, we must turn our sights from the work of the last century towards a nascent but thriving field: *Artificial Intelligence*.

# ELIZA and Humane Interactive Artificial Intelligence

I propose that we partner with Artificial Intelligence experts to integrate [ELIZA](https://en.wikipedia.org/wiki/ELIZA), a groundbreaking implementation of the human brain, into the TypeScript compiler.

ELIZA not only communicates issues on a human level - it is *interactive*. Instead of running a set of `.ts` and `.tsx` punchcards into a mainframe or whatever, ELIZA will allow you to engage on a terminal to *speak directly with the TypeScript compiler*.

Here is an example of an error TypeScript provides today:

```ts
example/foo.ts:9:6 - error TS1005: '}' expected.

9 |   }
       

  example/foo.ts:6:30
  6 | function foo(thing: boolean) {
                                   ~
  The parser expected to find a '}' to match the '{' token here.
```

What exactly is a "parser" and why is it trying to "find" a "token" "here"?

ELIZA won't do this. ELIZA has HEART (**H**umanoid **E**mpathy **A**nd **R**aw **T**omatoes). Here is an example of ELIZA in ACTION (**A**utonomy **C**omplete **T**o **I**ntelligent **O**rganization - **N**ice!).

```
ELIZA: Is there something bothering you, that you'd like to talk about?

YOU: function doSomething() { } function foo(thing: boolean) { if (thing) { doSomething(); }.

ELIZA: By the way, please understand that I can't always give you an attuned response.
-- But, please go on.

YOU: That was the end of my code.

ELIZA: That is interesting. Please continue.
```

There! ELIZA knows that your code can't be complete because it's missing a curly brace! No need to talk about *parsers* and *tokens* or even mention the word "error"!

TypeScript integration can be done across different implementations of ELIZA. This is useful if you need to change things up or get a second opinion on your code. Here's a similar interaction with a different ELIZA implementation.

```
> Hello, I am Eliza. I'll be your therapist today. 

*  function doSomething() {      }  function foo(thing: unknown) {     if (thing) {         doSomething();     }

> It is nice to be chatting with you. 

* Thank you, it is nice to be chatting with you too!

> We were discussing you, not me. 

* Uh, okay, good point. I'm just wondering if I wrote my code good

> How long have you been just wondering if you wrote your code good?

* I guess ever since I started coding I've been dealing with some level of imposter syndrome. When I first interviewed at Microsoft for an intern position, one of the interviewers even told me that I didn't belo-
```

*Wow!* I cannot believe that ELIZA goes beyond the code and dives right for the soul.

Gone are the days where you handed your code to a *wizard* during code review to be told you forgot a space after the `if` keyword.
Instead, you can ignore your coworkers and speak to the compiler all day.

``` 
* Is there anything wrong with my formatting?

> What does that suggest to you? 

* I just get a little bit obsessive about code formatting

> That is an interesting response. Let me make anote of that for next time. 

* You forgot a space between "a" and "note"

> Oh... Let's move on to something else for a bit.  forgot a space between" a" and" note"?
```

Compiler bug? No! ELIZA exhibits human traits and makes mistakes just like the rest of us.

# Timeline

Given enough community support and interest, I would love to get this implemented a year from today (April 1st, 2021). Please let us know your level of interest to see if we can prioritize this.