@@ -19,7 +19,8 @@ import { URI } from 'vscode-uri';
19
19
import { VirtualGtsCode } from './gts-virtual-code.js' ;
20
20
import { augmentDiagnostic } from '../transform/diagnostics/augmentation.js' ;
21
21
import MappingTree from '../transform/template/mapping-tree.js' ;
22
- import { TransformedModule } from '../transform/index.js' ;
22
+ import { Directive , TransformedModule } from '../transform/index.js' ;
23
+ import { Range } from '../transform/template/transformed-module.js' ;
23
24
24
25
const connection = createConnection ( ) ;
25
26
@@ -133,7 +134,7 @@ function filterAndAugmentDiagnostics(
133
134
}
134
135
135
136
return cachedVirtualCode ;
136
- }
137
+ } ;
137
138
138
139
const mappingForDiagnostic = ( diagnostic : vscode . Diagnostic ) : MappingTree | null = > {
139
140
const transformedModule = fetchVirtualCode ( ) ?. transformedModule ;
@@ -151,16 +152,65 @@ function filterAndAugmentDiagnostics(
151
152
152
153
const allDiagnostics : vscode . Diagnostic [ ] = [ ] ;
153
154
154
- return diagnostics . forEach ( ( diagnostic ) => {
155
+ const augmentedDiagnostics = diagnostics . map ( ( diagnostic ) => {
155
156
diagnostic = {
156
157
...diagnostic ,
157
158
source : 'glint' ,
158
159
} ;
159
160
160
- diagnostic = augmentDiagnostic ( diagnostic as any , mappingForDiagnostic ) ;
161
+ return augmentDiagnostic ( diagnostic as any , mappingForDiagnostic ) ;
162
+ } ) ;
163
+
164
+ if ( augmentedDiagnostics . length === 0 ) {
165
+ return [ ] ;
166
+ }
167
+
168
+ let unusedExpectErrors = new Set < Directive > ( ) ;
169
+ const transformedModule = fetchVirtualCode ( ) ?. transformedModule ;
170
+ if ( transformedModule ) {
171
+ transformedModule . directives . forEach ( ( directive ) => {
172
+ if ( directive . kind === 'expect-error' ) {
173
+ unusedExpectErrors . add ( directive ) ;
174
+ }
175
+ } ) ;
176
+ }
177
+
178
+ augmentedDiagnostics . forEach ( ( diagnostic ) => {
179
+ // Diagnostic is probably for transformed TS code.
180
+ // At this point in Volar we are returning diagnostics for the transformed TS code,
181
+ // which does not have a representation of ts-expect-error in it.
182
+ // And so when i try and find the transformedModule, the directives are
183
+ // going to be the source .gts file.
184
+ //
185
+ // so either:
186
+ // 1. translate directives into transformed TS code to see if they match the area of effect, or
187
+ // 2. MAYBE we represent the ts-expect-error in the transformed TS code, and then we can find it.
188
+
189
+ // let appliedDirective = transformedModule?.directives.find((directive) => {
190
+ // const diagnosticStart = document.offsetAt(diagnostic.range.start);
191
+ // return (
192
+ // // TODO: when would the filename ever be different? uncomment and fix?
193
+ // // directive.source.filename === diagnostic.file.fileName &&
194
+ // directive.areaOfEffect.start <= diagnosticStart &&
195
+ // directive.areaOfEffect.end > diagnosticStart
196
+ // );
197
+ // });
161
198
162
199
allDiagnostics . push ( diagnostic ) ;
163
200
} ) ;
201
+
202
+ // for (let directive of unusedExpectErrors) {
203
+ // allDiagnostics.push(
204
+ // createTransformDiagnostic(
205
+ // ts,
206
+ // directive.source,
207
+ // `Unused '@glint-expect-error' directive.`,
208
+ // directive.location
209
+ // )
210
+ // );
211
+ // }
212
+
213
+ return allDiagnostics ;
164
214
}
165
215
166
216
// connection.onRequest('mdx/toggleDelete', async (parameters) => {
0 commit comments