Skip to content

fix: remove spurious allowJs mismatch warning and fix patchTs singleton#184

Draft
wagenet wants to merge 6 commits intoember-tooling:mainfrom
wagenet:fix/spurious-allow-gjs-warning
Draft

fix: remove spurious allowJs mismatch warning and fix patchTs singleton#184
wagenet wants to merge 6 commits intoember-tooling:mainfrom
wagenet:fix/spurious-allow-gjs-warning

Conversation

@wagenet
Copy link
Copy Markdown
Contributor

@wagenet wagenet commented Mar 18, 2026

Summary

  • Remove spurious allowJs does not match warning from both the Glint and non-Glint parse paths. The warning fired because extraFileExtensions: ['.gts', '.gjs'] causes the TS program to have allowJs: true regardless of tsconfig — the mismatch was self-caused and could not be resolved by users setting allowGjs explicitly. Cleaned up now-unused allowGjsWasSet/actualAllowGjs variables and simplified parseWithGlint's signature.
  • Fix patchTs singleton freezing allowGjs: move the allowGjs = ... assignment above the isPatched early-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 different allowJs values.

Test plan

  • patchTs allowGjs singleton — verifies the singleton fix directly: second call with a different value reflects the new value
  • allowGjs mismatch warning — confirms no allowJs does not match warning fires when parsing .gts against a tsconfig with allowJs: false
  • All existing tests pass (pnpm test)

🤖 Generated with Claude Code

@wagenet wagenet marked this pull request as draft March 18, 2026 22:25
wagenet and others added 4 commits March 18, 2026 15:51
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>
@wagenet wagenet force-pushed the fix/spurious-allow-gjs-warning branch from be98eda to 34b131c Compare March 19, 2026 00:19
wagenet and others added 2 commits March 18, 2026 17:33
- 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>
@NullVoxPopuli
Copy link
Copy Markdown
Member

just saw all the noise this is gonna clean up internally 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants