fix: remove spurious allowJs mismatch warning and fix patchTs singleton#184
Draft
wagenet wants to merge 6 commits intoember-tooling:mainfrom
Draft
fix: remove spurious allowJs mismatch warning and fix patchTs singleton#184wagenet wants to merge 6 commits intoember-tooling:mainfrom
wagenet wants to merge 6 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>
The warning fired because extraFileExtensions forces allowJs:true in the TS program regardless of tsconfig, so the mismatch was self-caused and could not be fixed by users setting allowGjs explicitly. Also move allowGjs assignment above the isPatched guard in patchTs so the value is updated on every call, not frozen to the first invocation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
be98eda to
34b131c
Compare
- glint-utils.js, remap.js: replace require/module.exports with ESM imports and named exports to match the project's "type":"module" convention - transforms.js: remove matchedTemplates Set that was created and added to but never read Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
just saw all the noise this is gonna clean up internally 🎉 |
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
allowJs does not matchwarning from both the Glint and non-Glint parse paths. The warning fired becauseextraFileExtensions: ['.gts', '.gjs']causes the TS program to haveallowJs: trueregardless of tsconfig — the mismatch was self-caused and could not be resolved by users settingallowGjsexplicitly. Cleaned up now-unusedallowGjsWasSet/actualAllowGjsvariables and simplifiedparseWithGlint's signature.patchTssingleton freezingallowGjs: move theallowGjs = ...assignment above theisPatchedearly-return guard so the module-scoped variable is updated on every call, not locked to the value from the first invocation. This matters when multiple tsconfigs in a single lint run have differentallowJsvalues.Test plan
patchTs allowGjs singleton— verifies the singleton fix directly: second call with a different value reflects the new valueallowGjs mismatch warning— confirms noallowJs does not matchwarning fires when parsing.gtsagainst a tsconfig withallowJs: falsepnpm test)🤖 Generated with Claude Code