Skip to content

Commit e0078a7

Browse files
committed
a few tests passing
1 parent d916ef5 commit e0078a7

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

packages/core/src/transform/diagnostics/augmentation.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type ts from 'typescript';
22
import { Diagnostic } from './index.js';
33
import GlimmerASTMappingTree, { MappingSource } from '../template/glimmer-ast-mapping-tree.js';
4-
4+
import TransformedModule from '../template/transformed-module.js';
55
export function augmentDiagnostics<T extends Diagnostic>(
6-
transformedModule: any,
6+
transformedModule: TransformedModule,
77
diagnostics: T[],
88
): T[] {
99
const mappingForDiagnostic = (diagnostic: ts.Diagnostic): GlimmerASTMappingTree | null => {
@@ -26,8 +26,32 @@ export function augmentDiagnostics<T extends Diagnostic>(
2626
return rangeWithMappingAndSource.mapping || null;
2727
};
2828

29-
// @ts-expect-error not sure how to fix
30-
return diagnostics.map((diagnostic) => rewriteMessageText(diagnostic, mappingForDiagnostic));
29+
const augmentedDiagnostics: T[] = [];
30+
31+
for (const diagnostic of diagnostics) {
32+
const augmentedDiagnostic = rewriteMessageText(diagnostic, mappingForDiagnostic);
33+
34+
const mapping = mappingForDiagnostic(diagnostic);
35+
36+
if (mapping) {
37+
const appliedDirective = transformedModule.directives.find(
38+
(directive) =>
39+
// directive.source.filename === augmentedDiagnostic.file?.fileName &&
40+
directive.areaOfEffect.start <= augmentedDiagnostic.start! &&
41+
directive.areaOfEffect.end > augmentedDiagnostic.start!,
42+
);
43+
44+
if (appliedDirective) {
45+
// Filter out this diagnostic; its covered by a directive.
46+
continue;
47+
}
48+
}
49+
50+
// @ts-expect-error not sure how to fix
51+
augmentedDiagnostics.push(augmentedDiagnostic);
52+
}
53+
54+
return augmentedDiagnostics;
3155
}
3256

3357
type DiagnosticHandler<T extends Diagnostic> = (

packages/core/src/transform/template/inlining/tagged-strings.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ export function calculateTaggedTemplateSpans(
9191
}
9292

9393
if (transformedTemplate.result) {
94+
for (let { kind, location, areaOfEffect } of transformedTemplate.result.directives) {
95+
directives.push({
96+
kind: kind,
97+
source: script,
98+
location: addOffset(location, templateLocation.start),
99+
areaOfEffect: addOffset(areaOfEffect, templateLocation.start),
100+
});
101+
}
102+
94103
partialSpans.push({
95104
originalFile: script,
96105
originalStart: templateLocation.start,

test-packages/package-test-core/__tests__/language-server/diagnostics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe('Language Server: Diagnostics (ts plugin)', () => {
169169
`);
170170
});
171171

172-
test.only('honors @glint-expect-error', async () => {
172+
test('honors @glint-expect-error', async () => {
173173
const componentA = stripIndent`
174174
import Component from '@glimmer/component';
175175

0 commit comments

Comments
 (0)