Integrate Glint for current-file TS transform (Phase 2)#157
Draft
wagenet wants to merge 3 commits intoember-tooling:mainfrom
Draft
Integrate Glint for current-file TS transform (Phase 2)#157wagenet wants to merge 3 commits intoember-tooling:mainfrom
wagenet wants to merge 3 commits intoember-tooling:mainfrom
Conversation
When @glint/ember-tsc is installed and a glint environment is configured in tsconfig, use Glint's rewriteModule() instead of transformForLint() to generate virtual .mts/.mjs file contents in the TS patch. This gives TypeScript proper type understanding of imported .gts/.gjs modules. Falls back to the existing transformForLint path when Glint is unavailable (not installed, Node < 22.12, no glint config, or transform error). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a Glint-based code path in parseForESLint that uses rewriteModule() for the file being linted, giving the TS type checker full understanding of template semantics. Positions are remapped from Glint's transformed-space back to original-space using correlatedSpans, then Glimmer AST is spliced in. - Create src/parser/remap.js with position remapping utilities - Add buildTemplateInfoFromGlint to glint-utils.js - Refactor preprocessGlimmerTemplates; add char-offset variant - Add matchByRangeOnly option to convertAst for Glint node types - Export ts instance from ts-patch.js - Add parseWithGlint orchestration in gjs-gts-parser.js Falls back to existing transformForLint path when Glint is unavailable or rewriteModule returns null. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove orphaned JSDoc block from transforms.js - Restore removed "why" comments in processGlimmerTemplates - Narrow matchByRangeOnly to Glint-specific node types instead of matching all AST nodes - Guard token splice against findIndex returning -1 - Deduplicate buildTemplateInfoFromGlint by originalStart offset - Remove unused templateNodes collection from remap.js - Log e.stack instead of e.message in Glint fallback catch - Remove unused preprocessedResult.code assignment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
conflicts! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.gts/.gjsfiles that uses Glint's transform to produce__glintDSL__calls TypeScript understands, then remaps AST positions back to original source and splices in Glimmer ASTremap.jsmodule handles offset mapping from Glint's transformed-space back to original-space for both AST nodes and tokenspreprocessGlimmerTemplatesinto a sharedprocessGlimmerTemplatescore, with a newpreprocessGlimmerTemplatesFromCharOffsetsvariant for the Glint pathconvertAstwithmatchByRangeOnlyoption to handle Glint's different node types (CallExpression vs TemplateLiteral)Test plan
remapOffset,remapAstPositions,remapTokensparseWithGlintwith a simple.gtsfile🤖 Generated with Claude Code