Skip to content

Commit 772157d

Browse files
committed
update method patching in completions for ts5.0
1 parent cf2a275 commit 772157d

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

typescript/src/completionsAtPosition.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -357,22 +357,23 @@ const patchBuiltinMethods = (c: GetConfig, languageService: ts.LanguageService,
357357
// TODO! when file name without with half-ending is typed it doesn't these completions! (seems ts bug, but probably can be fixed here)
358358
// e.g. /styles.css import './styles.c|' - no completions
359359
const oldGetSupportedExtensions = tsFull.getSupportedExtensions
360-
//@ts-expect-error monkey patch
361-
tsFull.getSupportedExtensions = (options, extraFileExtensions) => {
362-
addFileExtensions ??= getAddFileExtensions()
363-
// though I extensions could be just inlined as is
364-
return oldGetSupportedExtensions(
365-
options,
366-
extraFileExtensions?.length
367-
? extraFileExtensions
368-
: addFileExtensions.map(ext => ({
369-
extension: ext,
370-
isMixedContent: true,
371-
scriptKind: ts.ScriptKind.Deferred,
372-
})),
373-
)
374-
}
360+
Object.defineProperty(tsFull, 'getSupportedExtensions', {
361+
value: (options, extraFileExtensions) => {
362+
addFileExtensions ??= getAddFileExtensions()
363+
// though I extensions could be just inlined as is
364+
return oldGetSupportedExtensions(
365+
options,
366+
extraFileExtensions?.length
367+
? extraFileExtensions
368+
: addFileExtensions.map(ext => ({
369+
extension: ext,
370+
isMixedContent: true,
371+
scriptKind: ts.ScriptKind.Deferred,
372+
})),
373+
)
374+
},
375+
})
375376
return () => {
376-
tsFull.getSupportedExtensions = oldGetSupportedExtensions
377+
Object.defineProperty(tsFull, 'getSupportedExtensions', { value: oldGetSupportedExtensions })
377378
}
378379
}

0 commit comments

Comments
 (0)