@@ -252,66 +252,67 @@ export class SvelteCheck {
252
252
const isKitFile = snapshot ?. kitFile ?? false ;
253
253
const diagnostics : Diagnostic [ ] = [ ] ;
254
254
if ( ! skipDiagnosticsForFile ) {
255
- const originalDiagnostics = [
256
- ... lang . getSyntacticDiagnostics ( file . fileName ) ,
257
- ... lang . getSuggestionDiagnostics ( file . fileName ) ,
258
- ... lang . getSemanticDiagnostics ( file . fileName )
259
- ] ;
260
-
261
- for ( let diagnostic of originalDiagnostics ) {
262
- if ( ! diagnostic . start || ! diagnostic . length || ! isKitFile ) {
263
- diagnostics . push ( map ( diagnostic ) ) ;
264
- continue ;
265
- }
255
+ const diagnosticSources = [
256
+ ' getSyntacticDiagnostics' ,
257
+ ' getSuggestionDiagnostics' ,
258
+ ' getSemanticDiagnostics'
259
+ ] as const ;
260
+ for ( const diagnosticSource of diagnosticSources ) {
261
+ for ( let diagnostic of lang [ diagnosticSource ] ( file . fileName ) ) {
262
+ if ( ! diagnostic . start || ! diagnostic . length || ! isKitFile ) {
263
+ diagnostics . push ( map ( diagnostic ) ) ;
264
+ continue ;
265
+ }
266
266
267
- let range : Range | undefined = undefined ;
268
- const inGenerated = isInGeneratedCode (
269
- file . text ,
270
- diagnostic . start ,
271
- diagnostic . start + diagnostic . length
272
- ) ;
273
- if ( inGenerated && snapshot ) {
274
- const pos = snapshot . getOriginalPosition (
275
- snapshot . positionAt ( diagnostic . start )
267
+ let range : Range | undefined = undefined ;
268
+ const inGenerated = isInGeneratedCode (
269
+ file . text ,
270
+ diagnostic . start ,
271
+ diagnostic . start + diagnostic . length
276
272
) ;
277
- range = {
278
- start : pos ,
279
- end : {
280
- line : pos . line ,
281
- // adjust length so it doesn't spill over to the next line
282
- character : pos . character + 1
283
- }
284
- } ;
285
- // If not one of the specific error messages then filter out
286
- if ( diagnostic . code === 2307 ) {
287
- diagnostic = {
288
- ...diagnostic ,
289
- messageText :
290
- typeof diagnostic . messageText === 'string' &&
291
- diagnostic . messageText . includes ( './$types' )
292
- ? diagnostic . messageText +
293
- ` (this likely means that SvelteKit's type generation didn't run yet - try running it by executing 'npm run dev' or 'npm run build')`
294
- : diagnostic . messageText
273
+ if ( inGenerated && snapshot ) {
274
+ const pos = snapshot . getOriginalPosition (
275
+ snapshot . positionAt ( diagnostic . start )
276
+ ) ;
277
+ range = {
278
+ start : pos ,
279
+ end : {
280
+ line : pos . line ,
281
+ // adjust length so it doesn't spill over to the next line
282
+ character : pos . character + 1
283
+ }
295
284
} ;
296
- } else if ( diagnostic . code === 2694 ) {
297
- diagnostic = {
298
- ...diagnostic ,
299
- messageText :
300
- typeof diagnostic . messageText === 'string' &&
301
- diagnostic . messageText . includes ( '/$types' )
302
- ? diagnostic . messageText +
303
- ` (this likely means that SvelteKit's generated types are out of date - try rerunning it by executing 'npm run dev' or 'npm run build')`
304
- : diagnostic . messageText
305
- } ;
306
- } else if (
307
- diagnostic . code !==
308
- 2355 /* A function whose declared type is neither 'void' nor 'any' must return a value */
309
- ) {
310
- continue ;
285
+ // If not one of the specific error messages then filter out
286
+ if ( diagnostic . code === 2307 ) {
287
+ diagnostic = {
288
+ ...diagnostic ,
289
+ messageText :
290
+ typeof diagnostic . messageText === 'string' &&
291
+ diagnostic . messageText . includes ( './$types' )
292
+ ? diagnostic . messageText +
293
+ ` (this likely means that SvelteKit's type generation didn't run yet - try running it by executing 'npm run dev' or 'npm run build')`
294
+ : diagnostic . messageText
295
+ } ;
296
+ } else if ( diagnostic . code === 2694 ) {
297
+ diagnostic = {
298
+ ...diagnostic ,
299
+ messageText :
300
+ typeof diagnostic . messageText === 'string' &&
301
+ diagnostic . messageText . includes ( '/$types' )
302
+ ? diagnostic . messageText +
303
+ ` (this likely means that SvelteKit's generated types are out of date - try rerunning it by executing 'npm run dev' or 'npm run build')`
304
+ : diagnostic . messageText
305
+ } ;
306
+ } else if (
307
+ diagnostic . code !==
308
+ 2355 /* A function whose declared type is neither 'void' nor 'any' must return a value */
309
+ ) {
310
+ continue ;
311
+ }
311
312
}
312
- }
313
313
314
- diagnostics . push ( map ( diagnostic , range ) ) ;
314
+ diagnostics . push ( map ( diagnostic , range ) ) ;
315
+ }
315
316
}
316
317
}
317
318
0 commit comments