Article Complete
AIM
‘AI Can’t Write the TypeScript Compiler’
‘AI Can’t Write the TypeScript Compiler’

‘AI Can’t Write the TypeScript Compiler’

“Our compiler is also not a typical piece of code. That’s why AI is bad at writing it: it hasn’t seen anything like it in the training set,” reveals Anders Hejlsberg.

Published Updated

Key takeaways

  • AI struggles to write the TypeScript compiler due to its unique codebase and implementation choices.
  • Anders Hejlsberg emphasises that AI has not encountered similar concepts in its training data.
  • Microsoft opted to syntactically translate TypeScript code into Go rather than relying on AI for the compiler's recreation.
  • The translated Go code was free of syntax errors but required further refinement to be fully usable.
5 min

AI could not write the TypeScript compiler despite attempts to use it for the task, Anders Hejlsberg, the creator of TypeScript and C#, said in a recent interview with developer Ryan Peterman.

“I know that AI could not write our compiler, the TypeScript compiler. It just can’t. We’ve tried it, and it can’t do it,” Hejlsberg said on The Peterman Pod.

Hejlsberg said the reason is partly that the TypeScript compiler is an unusual codebase containing concepts and implementation choices that AI is unlikely to have encountered together in its training data.

“Our compiler is also not a typical piece of code. That’s why AI is bad at writing it: it hasn’t seen anything like it in the training set,” Hejlsberg said.

While AI has seen other compilers and large software projects, Hejlsberg said the TypeScript compiler is sufficiently different from those examples to make it difficult for AI to reproduce.

“I’ve seen some compilers, but not like this one—not with these concepts, and not done the way we’re doing it,” he said.

Hejlsberg’s comments came during a discussion about Microsoft’s work last year to move the TypeScript compiler from its original JavaScript/TypeScript implementation to Go.

Rather than asking AI to recreate the compiler independently, the team built a tool that syntactically translated TypeScript code into Go.

That approach produced Go code without syntax errors, but it was not immediately usable. The generated code still treated types according to TypeScript’s rules rather than Go’s type system, meaning engineers had to refactor the code and redo data structures.

The experience also shaped Hejlsberg’s view of how AI should be used for large software projects. 

He believes simply giving an LLM the compiler’s hundreds of thousands of lines of code and asking it to translate everything would leave engineers to check the output for hallucinations.

The old compiler contains somewhere between half a million and 1 million lines of code, according to Hejlsberg. Without perfect test coverage, developers would still have to examine the AI-generated result to ensure it had not introduced errors.

Instead, Hejlsberg said AI could create a translation program that performs the conversion consistently.

“That’s always the thing about AI that people forget: it’s not deterministic. So you can’t really trust that it’s going to do the same thing twice,” Hejlsberg said.

That does not mean Hejlsberg believes AI has little value in software development. He said his team already uses it for more targeted work around the compiler.

“We use AI a lot in our internal processes around the compiler. Help it to write tests and to move pull requests and what have you. And whenever an issue is logged, first thing we do is put Copilot on and see if it can fix it for us.”

Hejlsberg acknowledged that AI is improving rapidly, but he remains sceptical that it will soon be able to handle every part of software development independently.


Membership

Stay ahead with AI insights.

Unlimited access to premium articles, exclusive analysis, and the stories shaping India's AI economy.

Subscribe now

AIM Americas

1190 Miraloma Way Suite P, Sunnyvale, CA 94085

AIM India

1st Floor, Sakti Statesman, Bellandur, Bengaluru – 560103

© 2026 AIM. All rights reserved.