@glint/ember-tsc 1.7.5 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"run-volar-tsc.d.ts","sourceRoot":"","sources":["../../src/cli/run-volar-tsc.ts"],"names":[],"mappings":"AAWA,wBAAgB,GAAG,IAAI,IAAI,CA+B1B"}
1
+ {"version":3,"file":"run-volar-tsc.d.ts","sourceRoot":"","sources":["../../src/cli/run-volar-tsc.ts"],"names":[],"mappings":"AAcA,wBAAgB,GAAG,IAAI,IAAI,CAgC1B"}
@@ -1,6 +1,8 @@
1
1
  import { runTsc } from '@volar/typescript/lib/quickstart/runTsc.js';
2
2
  import { createEmberLanguagePlugin } from '../volar/ember-language-plugin.js';
3
3
  import { findConfig } from '../config/index.js';
4
+ import { VirtualGtsCode } from '../volar/gts-virtual-code.js';
5
+ import { getTransformErrorDiagnostics } from '../transform/diagnostics/transform-errors.js';
4
6
  import { createRequire } from 'node:module';
5
7
  const require = createRequire(import.meta.url);
6
8
  // Loaded via CJS require so we can monkey-patch readFileSync; the ESM namespace
@@ -9,6 +11,7 @@ const require = createRequire(import.meta.url);
9
11
  const fs = require('node:fs');
10
12
  export function run() {
11
13
  patchVolarProxyForExtensionlessImports();
14
+ patchVolarDecorateProgramForContentTagErrors();
12
15
  let cwd = process.cwd();
13
16
  const options = {
14
17
  extraSupportedExtensions: ['.gjs', '.gts'],
@@ -73,4 +76,113 @@ function applyProxyPatches(source) {
73
76
  }
74
77
  return source.replace(literalsPattern, `$1${guard}$2`).replace(namesPattern, `$1${guard}$2`);
75
78
  }
79
+ // Volar's `runTsc` does not surface the content-tag parse errors that we attach
80
+ // to `TransformedModule.errors` when content-tag fails to parse a .gts/.gjs
81
+ // file. The transformed source is intentionally blanked to whitespace in that
82
+ // case (see `rewriteModule`) so TypeScript does not emit a flood of misleading
83
+ // errors against the still-unparsed `<template>` tags; the trade-off is that
84
+ // the underlying parse failure is silently dropped.
85
+ //
86
+ // In language-server / tsserver-plugin contexts that silence is fine because
87
+ // the parse error is re-surfaced by separate diagnostic providers. But the
88
+ // `ember-tsc` CLI runs `tsc` via volar's `runTsc` (the Program path), which has
89
+ // no such provider — so `ember-tsc --noEmit` would report no errors at all on
90
+ // a broken template tag.
91
+ //
92
+ // We bridge that gap here by hot-patching `decorateProgram` from
93
+ // `@volar/typescript`: every time volar decorates a freshly created Program,
94
+ // we wrap its diagnostic methods to also include the synthesized content-tag
95
+ // diagnostics for any `.gts`/`.gjs` source files involved.
96
+ function patchVolarDecorateProgramForContentTagErrors() {
97
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
98
+ const decorateModule = require('@volar/typescript/lib/node/decorateProgram.js');
99
+ const originalDecorateProgram = decorateModule.decorateProgram;
100
+ decorateModule.decorateProgram = (language, program) => {
101
+ originalDecorateProgram(language, program);
102
+ injectContentTagDiagnostics(language, program);
103
+ };
104
+ }
105
+ function injectContentTagDiagnostics(language, program) {
106
+ // Loaded lazily so the runtime `ts` namespace is available without changing
107
+ // the existing `import type ts` style at the top of the file.
108
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
109
+ const tsRuntime = require('typescript');
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ const lang = language;
112
+ // Cache of synthetic SourceFiles built from the original .gts/.gjs text,
113
+ // keyed by file name. We need our own SourceFile here because the one TS
114
+ // gives us via `program.getSourceFile` was built from the *transformed*
115
+ // (whitespace-blanked, on parse failure) text — so `--pretty` rendering
116
+ // would print an empty source line under the diagnostic header (see
117
+ // https://github.com/typed-ember/glint/pull/1149#discussion_r... for the
118
+ // bug report). The original text lives on volar's `sourceScript.snapshot`.
119
+ const originalSourceFiles = new Map();
120
+ const getOriginalSourceFile = (fileName) => {
121
+ const cached = originalSourceFiles.get(fileName);
122
+ if (cached)
123
+ return cached;
124
+ const sourceScript = lang.scripts.get(fileName);
125
+ const snapshot = sourceScript?.snapshot;
126
+ if (!snapshot)
127
+ return undefined;
128
+ const text = snapshot.getText(0, snapshot.getLength());
129
+ const sf = tsRuntime.createSourceFile(fileName, text, tsRuntime.ScriptTarget.Latest,
130
+ /* setParentNodes */ false);
131
+ originalSourceFiles.set(fileName, sf);
132
+ return sf;
133
+ };
134
+ // Returns the synthesized content-tag diagnostics for a given source file (or
135
+ // for every .gts/.gjs source file in the program when `sourceFile` is
136
+ // omitted). Diagnostic offsets are in original .gts/.gjs coordinates, which
137
+ // already match the synthetic SourceFile we attach.
138
+ const collectExtras = (sourceFile) => {
139
+ if (!sourceFile) {
140
+ const extras = [];
141
+ for (const sf of program.getSourceFiles()) {
142
+ extras.push(...collectExtras(sf));
143
+ }
144
+ return extras;
145
+ }
146
+ const sourceScript = lang.scripts.get(sourceFile.fileName);
147
+ const root = sourceScript?.generated?.root;
148
+ if (!(root instanceof VirtualGtsCode)) {
149
+ return [];
150
+ }
151
+ const transformedModule = root.transformedModule;
152
+ if (!transformedModule) {
153
+ return [];
154
+ }
155
+ // Render against the original .gts/.gjs text (not the SourceFile TS
156
+ // hands back, which holds the blanked transformed contents) so
157
+ // `tsc --pretty` prints the actual offending source line.
158
+ const originalSourceFile = getOriginalSourceFile(sourceFile.fileName) ?? sourceFile;
159
+ return getTransformErrorDiagnostics(transformedModule, originalSourceFile);
160
+ };
161
+ const wrapPerFileDiagnostics = (key) => {
162
+ // `getBindAndCheckDiagnostics` is the watch-mode counterpart and is also
163
+ // wrapped below via the same helper through a cast.
164
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
+ const original = program[key];
166
+ if (typeof original !== 'function') {
167
+ return;
168
+ }
169
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
170
+ program[key] = (sourceFile, cancellationToken) => {
171
+ const original$ = original.call(program, sourceFile, cancellationToken);
172
+ const extras = collectExtras(sourceFile);
173
+ return extras.length ? [...original$, ...extras] : original$;
174
+ };
175
+ };
176
+ wrapPerFileDiagnostics('getSyntacticDiagnostics');
177
+ wrapPerFileDiagnostics('getSemanticDiagnostics');
178
+ // `getBindAndCheckDiagnostics` is used by `tsc --noEmit --watch`; it has the
179
+ // same signature as the methods above but is not part of the public types.
180
+ wrapPerFileDiagnostics('getBindAndCheckDiagnostics');
181
+ const originalEmit = program.emit;
182
+ program.emit = (...args) => {
183
+ const result = originalEmit.apply(program, args);
184
+ const extras = collectExtras();
185
+ return extras.length ? { ...result, diagnostics: [...result.diagnostics, ...extras] } : result;
186
+ };
187
+ }
76
188
  //# sourceMappingURL=run-volar-tsc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-volar-tsc.js","sourceRoot":"","sources":["../../src/cli/run-volar-tsc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,gFAAgF;AAChF,0BAA0B;AAC1B,iEAAiE;AACjE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAA6B,CAAC;AAE1D,MAAM,UAAU,GAAG;IACjB,sCAAsC,EAAE,CAAC;IAEzC,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAExB,MAAM,OAAO,GAAG;QACd,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QAE1C,+EAA+E;QAC/E,6DAA6D;QAC7D,8HAA8H;QAC9H,EAAE;QACF,uFAAuF;QACvF,EAAE;QACF,kLAAkL;QAClL,yFAAyF;QACzF,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;KAC1C,CAAC;IAEF,MAAM,IAAI,GAAG,GAAS,EAAE,CACtB,MAAM,CAAC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,oDAAoD;QACpD,8DAA8D;QAC9D,MAAM,QAAQ,GAAI,OAAe,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QACD,8DAA8D;QAC7D,OAAe,CAAC,GAAG,CAAC,GAAG,CACtB,UAA0B,EAC1B,iBAAwC,EACd,EAAE;YAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAC7B,OAAO,EACP,UAAU,EACV,iBAAiB,CACU,CAAC;YAC9B,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;YACzC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/D,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,sBAAsB,CAAC,yBAAyB,CAAC,CAAC;IAClD,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;IACjD,6EAA6E;IAC7E,2EAA2E;IAC3E,sBAAsB,CAAC,4BAAoE,CAAC,CAAC;IAE7F,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAClC,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACjG,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/environment-ember-template-imports/-private/environment/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA0B,MAAM,+BAA+B,CAAC;AAI/F,MAAM,CAAC,OAAO,UAAU,+BAA+B,CACrD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,sBAAsB,CAwGxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/environment-ember-template-imports/-private/environment/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAA0B,MAAM,+BAA+B,CAAC;AAqC/F,MAAM,CAAC,OAAO,UAAU,+BAA+B,CACrD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,sBAAsB,CAwGxB"}
@@ -1,5 +1,41 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { preprocess } from './preprocess.js';
2
3
  import { transform } from './transform.js';
4
+ /**
5
+ * Probe for the ember-source >= 7.1 built-in keyword set at config-load time.
6
+ *
7
+ * The 7.1 keywords (and, or, eq, fn, hash, not, gt/gte/lt/lte/neq, on, element,
8
+ * array) ship with ember-source 7.1 (RFCs 389, 470, 560, 561, 562, 997, 998,
9
+ * 999, 1000). On older versions consumers must import them from
10
+ * `ember-truth-helpers` / `@ember/helper`. Including these names in the strict
11
+ * mode `globals` set unconditionally suppresses TypeScript's
12
+ * "Cannot find name 'X'" diagnostic on <7.1 (because the transform emits
13
+ * `__glintDSL__.Globals.X` instead of a bare `X`), which in turn disables the
14
+ * `Add import from '...'` quick-fix and IDE autocomplete from user imports.
15
+ *
16
+ * Resolving from this module's URL means the probe walks the consumer's
17
+ * `node_modules` tree, so it reflects the host project's installed
18
+ * `ember-source`. Any failure (missing package, unreadable JSON, malformed
19
+ * version) collapses to `false` so the safe default is to assume the
20
+ * consumer is on a pre-7.1 build and let users import explicitly.
21
+ */
22
+ function hasEmber71BuiltIns() {
23
+ try {
24
+ const require_ = createRequire(import.meta.url);
25
+ const pkg = require_('ember-source/package.json');
26
+ if (typeof pkg.version !== 'string')
27
+ return false;
28
+ const [majorStr, minorStr] = pkg.version.split('.', 2);
29
+ const major = Number(majorStr);
30
+ const minor = Number(minorStr);
31
+ if (!Number.isFinite(major) || !Number.isFinite(minor))
32
+ return false;
33
+ return major > 7 || (major === 7 && minor >= 1);
34
+ }
35
+ catch {
36
+ return false;
37
+ }
38
+ }
3
39
  export default function emberTemplateImportsEnvironment(options) {
4
40
  let additionalSpecialForms = typeof options['additionalSpecialForms'] === 'object'
5
41
  ? options['additionalSpecialForms']
@@ -78,7 +114,7 @@ export default function emberTemplateImportsEnvironment(options) {
78
114
  },
79
115
  globals: [
80
116
  ...globalsForEmber,
81
- ...globalsForEmber71,
117
+ ...(hasEmber71BuiltIns() ? globalsForEmber71 : []),
82
118
  ...Object.keys(additionalGlobalSpecialForms),
83
119
  ...additionalGlobals,
84
120
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/environment-ember-template-imports/-private/environment/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,+BAA+B,CACrD,OAAgC;IAEhC,IAAI,sBAAsB,GACxB,OAAO,OAAO,CAAC,wBAAwB,CAAC,KAAK,QAAQ;QACnD,CAAC,CAAE,OAAO,CAAC,wBAAwB,CAA4B;QAC/D,CAAC,CAAC,EAAE,CAAC;IAET,MAAM,4BAA4B,GAAG,sBAAsB,CAAC,OAAO,IAAI,EAAE,CAAC;IAE1E,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACnE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC9B,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,eAAe,GAAG;QACtB,QAAQ;QACR,WAAW;QACX,UAAU;QACV,MAAM;QACN,SAAS;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;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/environment-ember-template-imports/-private/environment/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,kBAAkB;IACzB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,2BAA2B,CAA0B,CAAC;QAC3E,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAClD,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACrE,OAAO,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,+BAA+B,CACrD,OAAgC;IAEhC,IAAI,sBAAsB,GACxB,OAAO,OAAO,CAAC,wBAAwB,CAAC,KAAK,QAAQ;QACnD,CAAC,CAAE,OAAO,CAA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AAG,sBAAsB,CAAC,OAAO;yBAClC;qBACF;oBACD,OAAO,EAAE;wBACP,GAAG,eAAe;wBAClB,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;wBAClD,GAAG,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC;wBAC5C,GAAG,iBAAiB;qBACrB;iBACF;aACF;SACF;QACD,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,cAAc;gBACpB,UAAU;gBACV,SAAS;aACV;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,gBAAgB;gBACtB,UAAU;gBACV,SAAS;aACV;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -64,16 +64,43 @@ function calculateCorrelatedSpans(ts, script, environment, clientId) {
64
64
  });
65
65
  }
66
66
  else if ('isContentTagError' in error && error.isContentTagError) {
67
- // these lines exclude the line with the error, because
68
- // adding the column offset will get us on to the line with the error
69
- let lines = script.contents.split('\n').slice(0, error.line);
70
- let start = lines.reduce((sum, line) => sum + line.length, 0) + error.column - 1;
71
- let end = start + 1;
67
+ // Translate content-tag's 1-based (line, column) into an absolute
68
+ // offset in the original source. We use the line/column verbatim
69
+ // (rather than shifting back a line) so the diagnostic lands exactly
70
+ // where content-tag's own snippet points including for cases like
71
+ // `Unexpected eof` where the report sits at the end of a broken
72
+ // closing tag. The previous implementation summed the first
73
+ // `error.line` lines' lengths *without* their newlines, which by
74
+ // coincidence landed on the line above for some inputs and pointed
75
+ // at a blank line (or past EOF) for others (e.g. a `.gts` ending in
76
+ // `</templat\n`, which would render an empty source snippet).
77
+ let lines = script.contents.split('\n');
78
+ let lineIdx = Math.max(0, Math.min(error.line - 1, lines.length - 1));
79
+ let lineStart = 0;
80
+ for (let i = 0; i < lineIdx; i++) {
81
+ lineStart += lines[i].length + 1; // +1 for the consumed `\n`
82
+ }
83
+ let lineLength = lines[lineIdx]?.length ?? 0;
84
+ // Clamp the column to the last *character* of the line, not the
85
+ // newline that follows it. Otherwise a 1-char-wide diagnostic at
86
+ // (line N, col past EOL) would span across the `\n` into line N+1
87
+ // and TS would render two source-snippet lines (the second one
88
+ // empty) instead of just the offending one.
89
+ let col = lineLength === 0 ? 0 : Math.max(0, Math.min(error.column - 1, lineLength - 1));
90
+ let start = lineStart + col;
91
+ let end = Math.min(start + 1, script.contents.length);
72
92
  errors.push({
73
93
  isContentTagError: true,
74
- // we have to show the "help" because content-tag has different line numbers
75
- // than we are able to discern ourselves.
76
- message: error.message + '\n\n' + error.help,
94
+ // Use only `error.message` here. `error.help` is content-tag's pretty-
95
+ // printed source snippet with its own (1-based, post-error-line) line
96
+ // numbers, which conflict with the line/column the surrounding
97
+ // diagnostic surface (tsc, tsserver, LSP) reports for `location`.
98
+ // Including both produced output like
99
+ // src/Foo.gts(6,11): error TS0: Unexpected token ...
100
+ //
101
+ // 7 │ }
102
+ // where the two line numbers disagree and confuse readers.
103
+ message: error.message,
77
104
  source: script,
78
105
  location: {
79
106
  start,
@@ -1 +1 @@
1
- {"version":3,"file":"rewrite-module.js","sourceRoot":"","sources":["../../../src/transform/template/rewrite-module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,MAAM,EAAS,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,iBAKN,MAAM,yBAAyB,CAAC;AASjC;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,EAAS,EACT,EAAE,MAAM,EAAgB,EACxB,WAA6B,EAC7B,QAAiB;IAEjB,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,wBAAwB,CACjE,EAAE,EACF,MAAM,EACN,WAAW,EACX,QAAQ,CACT,CAAC;IAEF,IAAI,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC3C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,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC;QACzD,IAAI,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,IAAI,QAAQ,GAAG,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACtC,gBAAgB;gBACd,QAAQ,CAAC,gBAAgB;oBACzB,QAAQ,CAAC,iBAAiB,CAAC,MAAM;oBACjC,CAAC,OAAO,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;QACjF,CAAC;QAED,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,wBAAwB,CAAC,MAAkB;IAClD,OAAO;QACL,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,CAAC;QAChB,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,CAAC;QACjB,iBAAiB,EAAE,0DAA0D;KAC9E,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glint/ember-tsc",
3
- "version": "1.7.5",
3
+ "version": "1.8.1",
4
4
  "repository": "typed-ember/glint",
5
5
  "description": "A CLI for performing typechecking on Glimmer templates",
6
6
  "license": "MIT",
@@ -82,7 +82,7 @@
82
82
  "vscode-languageserver-protocol": "^3.17.5",
83
83
  "vscode-languageserver-textdocument": "^1.0.12",
84
84
  "vscode-uri": "^3.1.0",
85
- "@glint/template": "1.7.7"
85
+ "@glint/template": "1.7.8"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@glimmer/component": "^2.0.0",
@@ -97,8 +97,8 @@
97
97
  "execa": "^4.0.1",
98
98
  "strip-ansi": "^6.0.0",
99
99
  "typescript": "^5.9.3",
100
- "@glint/type-test": "2.0.1",
101
- "glint-monorepo-test-utils": "0.0.0"
100
+ "glint-monorepo-test-utils": "0.0.0",
101
+ "@glint/type-test": "2.0.1"
102
102
  },
103
103
  "publishConfig": {
104
104
  "access": "public"
@@ -1,6 +1,9 @@
1
1
  import { runTsc } from '@volar/typescript/lib/quickstart/runTsc.js';
2
+ import type ts from 'typescript';
2
3
  import { createEmberLanguagePlugin } from '../volar/ember-language-plugin.js';
3
4
  import { findConfig } from '../config/index.js';
5
+ import { VirtualGtsCode } from '../volar/gts-virtual-code.js';
6
+ import { getTransformErrorDiagnostics } from '../transform/diagnostics/transform-errors.js';
4
7
 
5
8
  import { createRequire } from 'node:module';
6
9
  const require = createRequire(import.meta.url);
@@ -11,6 +14,7 @@ const fs = require('node:fs') as typeof import('node:fs');
11
14
 
12
15
  export function run(): void {
13
16
  patchVolarProxyForExtensionlessImports();
17
+ patchVolarDecorateProgramForContentTagErrors();
14
18
 
15
19
  let cwd = process.cwd();
16
20
 
@@ -89,3 +93,135 @@ function applyProxyPatches(source: string): string {
89
93
 
90
94
  return source.replace(literalsPattern, `$1${guard}$2`).replace(namesPattern, `$1${guard}$2`);
91
95
  }
96
+
97
+ // Volar's `runTsc` does not surface the content-tag parse errors that we attach
98
+ // to `TransformedModule.errors` when content-tag fails to parse a .gts/.gjs
99
+ // file. The transformed source is intentionally blanked to whitespace in that
100
+ // case (see `rewriteModule`) so TypeScript does not emit a flood of misleading
101
+ // errors against the still-unparsed `<template>` tags; the trade-off is that
102
+ // the underlying parse failure is silently dropped.
103
+ //
104
+ // In language-server / tsserver-plugin contexts that silence is fine because
105
+ // the parse error is re-surfaced by separate diagnostic providers. But the
106
+ // `ember-tsc` CLI runs `tsc` via volar's `runTsc` (the Program path), which has
107
+ // no such provider — so `ember-tsc --noEmit` would report no errors at all on
108
+ // a broken template tag.
109
+ //
110
+ // We bridge that gap here by hot-patching `decorateProgram` from
111
+ // `@volar/typescript`: every time volar decorates a freshly created Program,
112
+ // we wrap its diagnostic methods to also include the synthesized content-tag
113
+ // diagnostics for any `.gts`/`.gjs` source files involved.
114
+ function patchVolarDecorateProgramForContentTagErrors(): void {
115
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
116
+ const decorateModule = require('@volar/typescript/lib/node/decorateProgram.js') as {
117
+ decorateProgram: (language: unknown, program: ts.Program) => void;
118
+ };
119
+ const originalDecorateProgram = decorateModule.decorateProgram;
120
+
121
+ decorateModule.decorateProgram = (language, program) => {
122
+ originalDecorateProgram(language, program);
123
+ injectContentTagDiagnostics(language, program);
124
+ };
125
+ }
126
+
127
+ function injectContentTagDiagnostics(language: unknown, program: ts.Program): void {
128
+ // Loaded lazily so the runtime `ts` namespace is available without changing
129
+ // the existing `import type ts` style at the top of the file.
130
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
131
+ const tsRuntime = require('typescript') as typeof ts;
132
+
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ const lang = language as { scripts: { get(id: string): any } };
135
+
136
+ // Cache of synthetic SourceFiles built from the original .gts/.gjs text,
137
+ // keyed by file name. We need our own SourceFile here because the one TS
138
+ // gives us via `program.getSourceFile` was built from the *transformed*
139
+ // (whitespace-blanked, on parse failure) text — so `--pretty` rendering
140
+ // would print an empty source line under the diagnostic header (see
141
+ // https://github.com/typed-ember/glint/pull/1149#discussion_r... for the
142
+ // bug report). The original text lives on volar's `sourceScript.snapshot`.
143
+ const originalSourceFiles = new Map<string, ts.SourceFile>();
144
+
145
+ const getOriginalSourceFile = (fileName: string): ts.SourceFile | undefined => {
146
+ const cached = originalSourceFiles.get(fileName);
147
+ if (cached) return cached;
148
+ const sourceScript = lang.scripts.get(fileName);
149
+ const snapshot = sourceScript?.snapshot as ts.IScriptSnapshot | undefined;
150
+ if (!snapshot) return undefined;
151
+ const text = snapshot.getText(0, snapshot.getLength());
152
+ const sf = tsRuntime.createSourceFile(
153
+ fileName,
154
+ text,
155
+ tsRuntime.ScriptTarget.Latest,
156
+ /* setParentNodes */ false,
157
+ );
158
+ originalSourceFiles.set(fileName, sf);
159
+ return sf;
160
+ };
161
+
162
+ // Returns the synthesized content-tag diagnostics for a given source file (or
163
+ // for every .gts/.gjs source file in the program when `sourceFile` is
164
+ // omitted). Diagnostic offsets are in original .gts/.gjs coordinates, which
165
+ // already match the synthetic SourceFile we attach.
166
+ const collectExtras = (sourceFile?: ts.SourceFile): ts.Diagnostic[] => {
167
+ if (!sourceFile) {
168
+ const extras: ts.Diagnostic[] = [];
169
+ for (const sf of program.getSourceFiles()) {
170
+ extras.push(...collectExtras(sf));
171
+ }
172
+ return extras;
173
+ }
174
+ const sourceScript = lang.scripts.get(sourceFile.fileName);
175
+ const root = sourceScript?.generated?.root;
176
+ if (!(root instanceof VirtualGtsCode)) {
177
+ return [];
178
+ }
179
+ const transformedModule = root.transformedModule;
180
+ if (!transformedModule) {
181
+ return [];
182
+ }
183
+ // Render against the original .gts/.gjs text (not the SourceFile TS
184
+ // hands back, which holds the blanked transformed contents) so
185
+ // `tsc --pretty` prints the actual offending source line.
186
+ const originalSourceFile = getOriginalSourceFile(sourceFile.fileName) ?? sourceFile;
187
+ return getTransformErrorDiagnostics(transformedModule, originalSourceFile);
188
+ };
189
+
190
+ const wrapPerFileDiagnostics = <K extends 'getSyntacticDiagnostics' | 'getSemanticDiagnostics'>(
191
+ key: K,
192
+ ): void => {
193
+ // `getBindAndCheckDiagnostics` is the watch-mode counterpart and is also
194
+ // wrapped below via the same helper through a cast.
195
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
+ const original = (program as any)[key];
197
+ if (typeof original !== 'function') {
198
+ return;
199
+ }
200
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
+ (program as any)[key] = (
202
+ sourceFile?: ts.SourceFile,
203
+ cancellationToken?: ts.CancellationToken,
204
+ ): readonly ts.Diagnostic[] => {
205
+ const original$ = original.call(
206
+ program,
207
+ sourceFile,
208
+ cancellationToken,
209
+ ) as readonly ts.Diagnostic[];
210
+ const extras = collectExtras(sourceFile);
211
+ return extras.length ? [...original$, ...extras] : original$;
212
+ };
213
+ };
214
+
215
+ wrapPerFileDiagnostics('getSyntacticDiagnostics');
216
+ wrapPerFileDiagnostics('getSemanticDiagnostics');
217
+ // `getBindAndCheckDiagnostics` is used by `tsc --noEmit --watch`; it has the
218
+ // same signature as the methods above but is not part of the public types.
219
+ wrapPerFileDiagnostics('getBindAndCheckDiagnostics' as unknown as 'getSyntacticDiagnostics');
220
+
221
+ const originalEmit = program.emit;
222
+ program.emit = (...args) => {
223
+ const result = originalEmit.apply(program, args);
224
+ const extras = collectExtras();
225
+ return extras.length ? { ...result, diagnostics: [...result.diagnostics, ...extras] } : result;
226
+ };
227
+ }
@@ -1,7 +1,41 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { GlintEnvironmentConfig, GlintSpecialFormConfig } from '@glint/ember-tsc/config-types';
2
3
  import { preprocess } from './preprocess.js';
3
4
  import { transform } from './transform.js';
4
5
 
6
+ /**
7
+ * Probe for the ember-source >= 7.1 built-in keyword set at config-load time.
8
+ *
9
+ * The 7.1 keywords (and, or, eq, fn, hash, not, gt/gte/lt/lte/neq, on, element,
10
+ * array) ship with ember-source 7.1 (RFCs 389, 470, 560, 561, 562, 997, 998,
11
+ * 999, 1000). On older versions consumers must import them from
12
+ * `ember-truth-helpers` / `@ember/helper`. Including these names in the strict
13
+ * mode `globals` set unconditionally suppresses TypeScript's
14
+ * "Cannot find name 'X'" diagnostic on <7.1 (because the transform emits
15
+ * `__glintDSL__.Globals.X` instead of a bare `X`), which in turn disables the
16
+ * `Add import from '...'` quick-fix and IDE autocomplete from user imports.
17
+ *
18
+ * Resolving from this module's URL means the probe walks the consumer's
19
+ * `node_modules` tree, so it reflects the host project's installed
20
+ * `ember-source`. Any failure (missing package, unreadable JSON, malformed
21
+ * version) collapses to `false` so the safe default is to assume the
22
+ * consumer is on a pre-7.1 build and let users import explicitly.
23
+ */
24
+ function hasEmber71BuiltIns(): boolean {
25
+ try {
26
+ const require_ = createRequire(import.meta.url);
27
+ const pkg = require_('ember-source/package.json') as { version?: unknown };
28
+ if (typeof pkg.version !== 'string') return false;
29
+ const [majorStr, minorStr] = pkg.version.split('.', 2);
30
+ const major = Number(majorStr);
31
+ const minor = Number(minorStr);
32
+ if (!Number.isFinite(major) || !Number.isFinite(minor)) return false;
33
+ return major > 7 || (major === 7 && minor >= 1);
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+
5
39
  export default function emberTemplateImportsEnvironment(
6
40
  options: Record<string, unknown>,
7
41
  ): GlintEnvironmentConfig {
@@ -88,7 +122,7 @@ export default function emberTemplateImportsEnvironment(
88
122
  },
89
123
  globals: [
90
124
  ...globalsForEmber,
91
- ...globalsForEmber71,
125
+ ...(hasEmber71BuiltIns() ? globalsForEmber71 : []),
92
126
  ...Object.keys(additionalGlobalSpecialForms),
93
127
  ...additionalGlobals,
94
128
  ],
@@ -106,17 +106,44 @@ function calculateCorrelatedSpans(
106
106
  source: script,
107
107
  });
108
108
  } else if ('isContentTagError' in error && error.isContentTagError) {
109
- // these lines exclude the line with the error, because
110
- // adding the column offset will get us on to the line with the error
111
- let lines = script.contents.split('\n').slice(0, error.line);
112
- let start = lines.reduce((sum, line) => sum + line.length, 0) + error.column - 1;
113
- let end = start + 1;
109
+ // Translate content-tag's 1-based (line, column) into an absolute
110
+ // offset in the original source. We use the line/column verbatim
111
+ // (rather than shifting back a line) so the diagnostic lands exactly
112
+ // where content-tag's own snippet points including for cases like
113
+ // `Unexpected eof` where the report sits at the end of a broken
114
+ // closing tag. The previous implementation summed the first
115
+ // `error.line` lines' lengths *without* their newlines, which by
116
+ // coincidence landed on the line above for some inputs and pointed
117
+ // at a blank line (or past EOF) for others (e.g. a `.gts` ending in
118
+ // `</templat\n`, which would render an empty source snippet).
119
+ let lines = script.contents.split('\n');
120
+ let lineIdx = Math.max(0, Math.min(error.line - 1, lines.length - 1));
121
+ let lineStart = 0;
122
+ for (let i = 0; i < lineIdx; i++) {
123
+ lineStart += lines[i].length + 1; // +1 for the consumed `\n`
124
+ }
125
+ let lineLength = lines[lineIdx]?.length ?? 0;
126
+ // Clamp the column to the last *character* of the line, not the
127
+ // newline that follows it. Otherwise a 1-char-wide diagnostic at
128
+ // (line N, col past EOL) would span across the `\n` into line N+1
129
+ // and TS would render two source-snippet lines (the second one
130
+ // empty) instead of just the offending one.
131
+ let col = lineLength === 0 ? 0 : Math.max(0, Math.min(error.column - 1, lineLength - 1));
132
+ let start = lineStart + col;
133
+ let end = Math.min(start + 1, script.contents.length);
114
134
 
115
135
  errors.push({
116
136
  isContentTagError: true,
117
- // we have to show the "help" because content-tag has different line numbers
118
- // than we are able to discern ourselves.
119
- message: error.message + '\n\n' + error.help,
137
+ // Use only `error.message` here. `error.help` is content-tag's pretty-
138
+ // printed source snippet with its own (1-based, post-error-line) line
139
+ // numbers, which conflict with the line/column the surrounding
140
+ // diagnostic surface (tsc, tsserver, LSP) reports for `location`.
141
+ // Including both produced output like
142
+ // src/Foo.gts(6,11): error TS0: Unexpected token ...
143
+ //
144
+ // 7 │ }
145
+ // where the two line numbers disagree and confuse readers.
146
+ message: error.message,
120
147
  source: script,
121
148
  location: {
122
149
  start,
@@ -31,9 +31,12 @@ import { UniqueIdHelper } from '../intrinsics/unique-id';
31
31
  // 389 are only available at runtime when consumers are on ember-source >= 7.1.
32
32
  // We probe for the `eq` value re-export added by RFC 561 to decide whether to
33
33
  // expose the new keyword types. On older versions the probe collapses to the
34
- // empty type, so referencing e.g. `{{eq}}` falls back to whatever the user
35
- // has imported (or surfaces as an "unknown identifier" diagnostic), keeping
36
- // behaviour identical to today.
34
+ // empty type, so the 7.1 keyword members are entirely absent from `Globals` —
35
+ // referencing e.g. `{{eq}}` then surfaces TypeScript's standard
36
+ // "Property 'eq' does not exist on type 'Globals'" diagnostic, which triggers
37
+ // auto-import quick-fixes (`import { eq } from 'ember-truth-helpers'`) and
38
+ // lets user-scoped imports flow through completion and hover without being
39
+ // shadowed by a `never`-typed builtin.
37
40
  //
38
41
  // We probe a value export (`eq`) rather than the matching `EqHelper`
39
42
  // interface because `typeof import(...)` only surfaces the module's value
@@ -49,9 +52,6 @@ type EmberHelperExports = typeof import('@ember/helper');
49
52
 
50
53
  type HasEmber71BuiltIns = [EmberHelperExports] extends [{ eq: unknown }] ? true : false;
51
54
 
52
- /** Resolves to `T` only when ember-source >= 7.1 ships the new keyword set. */
53
- type Ember71Only<T> = HasEmber71BuiltIns extends true ? T : never;
54
-
55
55
  // The keyword vs global breakdown here is loosely matched with
56
56
  // the listing in http://emberjs.github.io/rfcs/0496-handlebars-strict-mode.html
57
57
 
@@ -243,12 +243,16 @@ interface KeywordsForEmber {
243
243
 
244
244
  /**
245
245
  * Built-in template keywords introduced by ember-source 7.1
246
- * (RFCs 389, 470, 560, 561, 562, 997, 998, 999, 1000). Each entry is gated by
247
- * `Ember71Only<T>` so the keyword resolves to `never` (and is therefore
248
- * effectively absent) when the consumer is on ember-source < 7.1. See the
249
- * `HasEmber71BuiltIns` probe at the top of this file.
246
+ * (RFCs 389, 470, 560, 561, 562, 997, 998, 999, 1000). The whole member set is
247
+ * gated by `HasEmber71BuiltIns` at the `Globals` intersection below, so when
248
+ * the consumer is on ember-source < 7.1 these property keys are absent from
249
+ * `Globals` entirely (rather than present as `never`). That lets TypeScript
250
+ * report `{{eq}}` / `{{and}}` / etc. as unknown properties and offer the
251
+ * "Add import from 'ember-truth-helpers'" / `@ember/helper` quick-fix, and
252
+ * keeps user-imported helpers from being shadowed by a `never`-typed builtin
253
+ * in completion and hover.
250
254
  */
251
- interface KeywordsForEmber71 {
255
+ interface KeywordsForEmber71Members {
252
256
  /**
253
257
  * The `{{and}}` helper evaluates arguments left to right, returning the first
254
258
  * falsy value (using Handlebars truthiness) or the right-most value if all
@@ -265,7 +269,7 @@ interface KeywordsForEmber71 {
265
269
  *
266
270
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/and
267
271
  */
268
- and: Ember71Only<AndHelper>;
272
+ and: AndHelper;
269
273
 
270
274
  /**
271
275
  * Using the `{{array}}` helper, you can pass arrays directly from the
@@ -286,7 +290,7 @@ interface KeywordsForEmber71 {
286
290
  *
287
291
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/array
288
292
  */
289
- array: Ember71Only<ArrayHelper>;
293
+ array: ArrayHelper;
290
294
 
291
295
  /**
292
296
  * The `{{element}}` helper lets you dynamically set the tag name of an
@@ -310,7 +314,7 @@ interface KeywordsForEmber71 {
310
314
  *
311
315
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/element
312
316
  */
313
- element: Ember71Only<ElementHelper>;
317
+ element: ElementHelper;
314
318
 
315
319
  /**
316
320
  * The `{{eq}}` helper returns `true` if its two arguments are strictly equal
@@ -327,7 +331,7 @@ interface KeywordsForEmber71 {
327
331
  *
328
332
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/eq
329
333
  */
330
- eq: Ember71Only<EqHelper>;
334
+ eq: EqHelper;
331
335
 
332
336
  /**
333
337
  * `{{fn}}` is a helper that receives a function and some arguments, and
@@ -351,7 +355,7 @@ interface KeywordsForEmber71 {
351
355
  *
352
356
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/fn
353
357
  */
354
- fn: Ember71Only<FnHelper>;
358
+ fn: FnHelper;
355
359
 
356
360
  /**
357
361
  * The `{{gt}}` helper returns `true` if the first argument is greater than
@@ -368,7 +372,7 @@ interface KeywordsForEmber71 {
368
372
  *
369
373
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/gt
370
374
  */
371
- gt: Ember71Only<GtHelper>;
375
+ gt: GtHelper;
372
376
 
373
377
  /**
374
378
  * The `{{gte}}` helper returns `true` if the first argument is greater than
@@ -385,7 +389,7 @@ interface KeywordsForEmber71 {
385
389
  *
386
390
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/gte
387
391
  */
388
- gte: Ember71Only<GteHelper>;
392
+ gte: GteHelper;
389
393
 
390
394
  /**
391
395
  * Using the `{{hash}}` helper, you can pass objects directly from the
@@ -404,7 +408,7 @@ interface KeywordsForEmber71 {
404
408
  *
405
409
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/hash
406
410
  */
407
- hash: Ember71Only<HashHelper>;
411
+ hash: HashHelper;
408
412
 
409
413
  /**
410
414
  * The `{{lt}}` helper returns `true` if the first argument is less than the
@@ -421,7 +425,7 @@ interface KeywordsForEmber71 {
421
425
  *
422
426
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/lt
423
427
  */
424
- lt: Ember71Only<LtHelper>;
428
+ lt: LtHelper;
425
429
 
426
430
  /**
427
431
  * The `{{lte}}` helper returns `true` if the first argument is less than or
@@ -438,7 +442,7 @@ interface KeywordsForEmber71 {
438
442
  *
439
443
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/lte
440
444
  */
441
- lte: Ember71Only<LteHelper>;
445
+ lte: LteHelper;
442
446
 
443
447
  /**
444
448
  * The `{{neq}}` helper returns `true` if its two arguments are strictly not
@@ -455,7 +459,7 @@ interface KeywordsForEmber71 {
455
459
  *
456
460
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/neq
457
461
  */
458
- neq: Ember71Only<NeqHelper>;
462
+ neq: NeqHelper;
459
463
 
460
464
  /**
461
465
  * The `{{not}}` helper returns the logical negation of its argument using
@@ -472,7 +476,7 @@ interface KeywordsForEmber71 {
472
476
  *
473
477
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/not
474
478
  */
475
- not: Ember71Only<NotHelper>;
479
+ not: NotHelper;
476
480
 
477
481
  /**
478
482
  * The `{{on}}` element modifier attaches an event listener to an element.
@@ -493,7 +497,7 @@ interface KeywordsForEmber71 {
493
497
  *
494
498
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fmodifier/on
495
499
  */
496
- on: Ember71Only<OnModifier>;
500
+ on: OnModifier;
497
501
 
498
502
  /**
499
503
  * The `{{or}}` helper evaluates arguments left to right, returning the first
@@ -511,7 +515,7 @@ interface KeywordsForEmber71 {
511
515
  *
512
516
  * @see https://api.emberjs.com/ember/release/functions/@ember%2Fhelper/or
513
517
  */
514
- or: Ember71Only<OrHelper>;
518
+ or: OrHelper;
515
519
  }
516
520
 
517
521
  /**
@@ -576,6 +580,12 @@ interface KeywordAliasesForEmber {
576
580
  unique_id: UniqueIdHelper;
577
581
  }
578
582
 
579
- interface Keywords extends KeywordsForEmber, KeywordsForEmber71, KeywordAliasesForEmber {}
583
+ interface Keywords extends KeywordsForEmber, KeywordAliasesForEmber {}
584
+
585
+ // When `HasEmber71BuiltIns` is `true`, the 7.1 keyword members are included on
586
+ // `Globals`; otherwise the conditional collapses to `{}` and the keys are
587
+ // absent so TypeScript surfaces "unknown identifier" diagnostics / auto-import
588
+ // quick-fixes for `{{and}}`, `{{eq}}`, etc.
589
+ type KeywordsForEmber71 = HasEmber71BuiltIns extends true ? KeywordsForEmber71Members : {};
580
590
 
581
- export const Globals: Keywords & Globals;
591
+ export const Globals: Keywords & KeywordsForEmber71 & Globals;
@@ -10,12 +10,18 @@ export type EventForName<Name extends string> = Name extends keyof HTMLElementEv
10
10
  ? HTMLElementEventMap[Name]
11
11
  : Event;
12
12
 
13
- export type OnModifier = abstract new <Name extends string>() => InstanceType<
13
+ export type OnModifier = abstract new <
14
+ Name extends string,
15
+ El extends Element = Element,
16
+ >() => InstanceType<
14
17
  ModifierLike<{
15
- Element: Element;
18
+ Element: El;
16
19
  Args: {
17
20
  Named: OnModifierArgs;
18
- Positional: [name: Name, callback: (event: EventForName<Name>) => void];
21
+ Positional: [
22
+ name: Name,
23
+ callback: (event: EventForName<Name> & { currentTarget: El }) => void,
24
+ ];
19
25
  };
20
26
  }>
21
27
  >;