diff --git a/buildTsPlugin.mjs b/buildTsPlugin.mjs index 511ac87c..4397d270 100644 --- a/buildTsPlugin.mjs +++ b/buildTsPlugin.mjs @@ -25,6 +25,7 @@ export const buildTsPlugin = async (/** @type {string} */ outDir, /** @type {str format: 'cjs', entryPoints: [entrypoint], outfile: join(outDir, 'index.js'), + mainFields: ['module', 'main'] }) } diff --git a/src/configurationType.ts b/src/configurationType.ts index ff40316d..32768fa2 100644 --- a/src/configurationType.ts +++ b/src/configurationType.ts @@ -107,6 +107,10 @@ export type Configuration = { * @default true */ 'jsxImproveElementsSuggestions.enabled': boolean + /** + * Requires restart TS server + * @default false + * */ // 'eventTypePatching.enable': boolean // 'globalTypedQuerySelector.enable': boolean, /** diff --git a/src/configurationTypeCache.jsonc b/src/configurationTypeCache.jsonc index 9aff1492..175dc83a 100644 --- a/src/configurationTypeCache.jsonc +++ b/src/configurationTypeCache.jsonc @@ -1,5 +1,5 @@ // GENERATED. DON'T EDIT MANUALLY -// md5hash: ba4b89b4b50869a61ab291839b74492d +// md5hash: 9c3812628516e353f3aa75256e99e8fa { "type": "object", "properties": { diff --git a/typescript/src/index.ts b/typescript/src/index.ts index bb2efefc..d646c5d5 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -12,6 +12,23 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t return { create(info: ts.server.PluginCreateInfo) { + // const realGetSnapshot = info.languageServiceHost.getScriptSnapshot + // info.languageServiceHost.getScriptSnapshot = fileName => { + // console.log('getSnapshot', fileName) + // return realGetSnapshot(fileName) + // } + // const realReadFile = info.serverHost.readFile + // info.serverHost.readFile = fileName => { + // let contents = realReadFile(fileName) + // if (fileName.endsWith('/node_modules/typescript/lib/lib.dom.d.ts') && c('eventTypePatching.enable')) { + // contents = contents + // ?.replace('interface EventTarget {', 'interface EventTarget extends HTMLElement {') + // .replace('"change": Event;', '"change": Event & {currentTarget: HTMLInputElement, target: HTMLInputElement};') + // .replace('"change": Event;', '"change": Event & {currentTarget: HTMLInputElement, target: HTMLInputElement};') + // .replace('"input": Event;', '"input": Event & {currentTarget: HTMLInputElement, target: HTMLInputElement};') + // } + // return contents + // } // const compilerOptions = typescript.convertCompilerOptionsFromJson(options.compilerOptions, options.sourcesRoot).options // console.log('getCompilationSettings', info.languageServiceHost.getCompilationSettings()) // info.languageServiceHost.getScriptSnapshot