Transforms Assemble: turning Handlebars into TypeScript
Channel: Sympolymathesy by Chris Krycho
Date: 2023-09-27

Chris Krycho and Dan Freeman show how Glint actually gets #typescript out of #emberjs Handlebars templates.

Ember RFC 0931: JS Representation of Template Tag: https://github.com/emberjs/rfcs/pull/931

The Glint project repository: https://github.com/typed-ember/glint
The Glint project documentation: https://typed-ember.gitbook.io/glint
The “signatures” RFC: https://github.com/emberjs/rfcs/pull/748
Ember.js: https://emberjs.com
Glimmer.js: https://glimmerjs.com

The Series:
1: https://www.youtube.com/watch?v=MLpP8D3cY7M&list=PLelyiwKWHHApkoeXQjwKPHPAHgKXZyl3t&index=1
2: https://www.youtube.com/watch?v=Xhv1jAV5cZI&list=PLelyiwKWHHApkoeXQjwKPHPAHgKXZyl3t&index=2
3: https://www.youtube.com/watch?v=6-TWGx8j9RU&list=PLelyiwKWHHApkoeXQjwKPHPAHgKXZyl3t&index=3
4: https://www.youtube.com/watch?v=9RjaREOmFAA&list=PLelyiwKWHHApkoeXQjwKPHPAHgKXZyl3t&index=4
5: https://www.youtube.com/watch?v=oqIAyLbp6Rc&list=PLelyiwKWHHApkoeXQjwKPHPAHgKXZyl3t&index=5

Chapters
00:00:00 Introduction
00:03:00 Review: Transforms in the architecture
00:03:52 Glint's rewriteModule function
00:08:12 Building up "spans"
00:11:00 Environment-driven shenanigans
00:15:45 Walking the TS AST to get transform errors
00:18:55 How environments work—again
00:25:35 Errors without locations (Chris is wrong!)
00:28:46 Comparing how standalone templates work (Chris is wrong again!)
00:35:38 Doing the the final transformation math (and spans!)
00:38:18 What is a TransformedModule?
00:39:28 templateToTypescript: how it’s organized
00:44:12 templateToTypescript: how it actually works
00:46:58 Why we emit text instead of TS ASTs
00:52:17 Mapper and its record and emit functions
00:59:16 The MappingTree, or how we actually do the mapping!
01:02:32 So that we can rewrite diagnostics
01:04:28 Wrapping up and previewing next time!