@@ -6,7 +6,6 @@ import type { Configuration } from '../../src/configurationType'
66import _ from 'lodash'
77import { GetConfig } from './types'
88import { getCompletionsAtPosition , PrevCompletionMap } from './completionsAtPosition'
9- import { getParameterListParts } from './completionGetMethodParameters'
109import { oneOf } from '@zardoy/utils'
1110import { isGoodPositionMethodCompletion } from './isGootPositionMethodCompletion'
1211
@@ -134,7 +133,7 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t
134133 proxy . getCodeFixesAtPosition = ( fileName , start , end , errorCodes , formatOptions , preferences ) => {
135134 let prior = info . languageService . getCodeFixesAtPosition ( fileName , start , end , errorCodes , formatOptions , preferences )
136135 // const scriptSnapshot = info.project.getScriptSnapshot(fileName)
137- const diagnostics = info . languageService . getSemanticDiagnostics ( fileName )
136+ const diagnostics = proxy . getSemanticDiagnostics ( fileName )
138137
139138 // https://github.com/Microsoft/TypeScript/blob/v4.5.5/src/compiler/diagnosticMessages.json#L458
140139 const appliableErrorCode = [ 1156 , 1157 ] . find ( code => errorCodes . includes ( code ) )
@@ -203,6 +202,22 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t
203202 return prior
204203 }
205204
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+
206221 info . languageService [ thisPluginMarker ] = true
207222
208223 return proxy
0 commit comments