@@ -6,7 +6,6 @@ import type { Configuration } from '../../src/configurationType'
6
6
import _ from 'lodash'
7
7
import { GetConfig } from './types'
8
8
import { getCompletionsAtPosition , PrevCompletionMap } from './completionsAtPosition'
9
- import { getParameterListParts } from './completionGetMethodParameters'
10
9
import { oneOf } from '@zardoy/utils'
11
10
import { isGoodPositionMethodCompletion } from './isGootPositionMethodCompletion'
12
11
@@ -134,7 +133,7 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t
134
133
proxy . getCodeFixesAtPosition = ( fileName , start , end , errorCodes , formatOptions , preferences ) => {
135
134
let prior = info . languageService . getCodeFixesAtPosition ( fileName , start , end , errorCodes , formatOptions , preferences )
136
135
// const scriptSnapshot = info.project.getScriptSnapshot(fileName)
137
- const diagnostics = info . languageService . getSemanticDiagnostics ( fileName )
136
+ const diagnostics = proxy . getSemanticDiagnostics ( fileName )
138
137
139
138
// https://github.com/Microsoft/TypeScript/blob/v4.5.5/src/compiler/diagnosticMessages.json#L458
140
139
const appliableErrorCode = [ 1156 , 1157 ] . find ( code => errorCodes . includes ( code ) )
@@ -203,6 +202,22 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t
203
202
return prior
204
203
}
205
204
205
+ proxy . getSemanticDiagnostics = fileName => {
206
+ let prior = info . languageService . getSemanticDiagnostics ( fileName )
207
+ if ( c ( 'supportTsDiagnosticDisableComment' ) ) {
208
+ const scriptSnapshot = info . project . getScriptSnapshot ( fileName ) !
209
+ const firstLine = scriptSnapshot . getText ( 0 , scriptSnapshot . getLength ( ) ) . split ( / \r ? \n / ) [ 0 ] !
210
+ if ( firstLine . startsWith ( '//' ) ) {
211
+ const match = firstLine . match ( / @ t s - d i a g n o s t i c - d i s a b l e ( ( \d + , ) * ( \d + ) ) / )
212
+ if ( match ) {
213
+ const codesToDisable = match [ 1 ] ! . split ( ', ' ) . map ( Number )
214
+ prior = prior . filter ( ( { code } ) => ! codesToDisable . includes ( code ) )
215
+ }
216
+ }
217
+ }
218
+ return prior
219
+ }
220
+
206
221
info . languageService [ thisPluginMarker ] = true
207
222
208
223
return proxy
0 commit comments