From 3e3e8cd2496fe4a6201d70fc6c8455c71591e055 Mon Sep 17 00:00:00 2001 From: Viijay-Kr Date: Mon, 1 Jul 2024 09:24:39 +0200 Subject: [PATCH] fix: mdx analyzer conflicts based on volar js proxy technique refs: https://github.com/volarjs/volar.js/pull/216 closes: https://github.com/Viijay-Kr/react-ts-css/issues/160#issuecomment-2198579932 --- src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index aa8eb7b..9e9fbff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,13 +19,21 @@ function init({ function create(info: ts.server.PluginCreateInfo) { // Set up decorator object settings = info.config as Config - const proxy: ts.LanguageService = Object.create(null) + const proxy: ts.LanguageService = new Proxy(info.languageService, { + get(target, p, receiver) { + return Reflect.get(target, p, receiver) + }, + set(target, p, newValue, receiver) { + return Reflect.set(target, p, newValue, receiver) + }, + }) for (let k of Object.keys(info.languageService) as Array< keyof ts.LanguageService >) { const x = info.languageService[k]! // @ts-expect-error - JS runtime trickery which is tricky to type tersely proxy[k] = (...args: Array<{}>) => + // @ts-expect-error - JS runtime trickery which is tricky to type tersely x.apply(info.languageService, args) }