Skip to content

Commit 90d83d0

Browse files
committed
WIP: add lib.dom eventTypePatching (disabled by default)
fix: crash on start
1 parent 3aca612 commit 90d83d0

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

buildTsPlugin.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const buildTsPlugin = async (/** @type {string} */ outDir, /** @type {str
2525
format: 'cjs',
2626
entryPoints: [entrypoint],
2727
outfile: join(outDir, 'index.js'),
28+
mainFields: ['module', 'main']
2829
})
2930
}
3031

src/configurationType.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export type Configuration = {
107107
* @default true
108108
*/
109109
'jsxImproveElementsSuggestions.enabled': boolean
110+
/**
111+
* Requires restart TS server
112+
* @default false
113+
* */
110114
// 'eventTypePatching.enable': boolean
111115
// 'globalTypedQuerySelector.enable': boolean,
112116
/**

src/configurationTypeCache.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// GENERATED. DON'T EDIT MANUALLY
2-
// md5hash: ba4b89b4b50869a61ab291839b74492d
2+
// md5hash: 9c3812628516e353f3aa75256e99e8fa
33
{
44
"type": "object",
55
"properties": {

typescript/src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t
1212

1313
return {
1414
create(info: ts.server.PluginCreateInfo) {
15+
// const realGetSnapshot = info.languageServiceHost.getScriptSnapshot
16+
// info.languageServiceHost.getScriptSnapshot = fileName => {
17+
// console.log('getSnapshot', fileName)
18+
// return realGetSnapshot(fileName)
19+
// }
20+
// const realReadFile = info.serverHost.readFile
21+
// info.serverHost.readFile = fileName => {
22+
// let contents = realReadFile(fileName)
23+
// if (fileName.endsWith('/node_modules/typescript/lib/lib.dom.d.ts') && c('eventTypePatching.enable')) {
24+
// contents = contents
25+
// ?.replace('interface EventTarget {', 'interface EventTarget extends HTMLElement {')
26+
// .replace('"change": Event;', '"change": Event & {currentTarget: HTMLInputElement, target: HTMLInputElement};')
27+
// .replace('"change": Event;', '"change": Event & {currentTarget: HTMLInputElement, target: HTMLInputElement};')
28+
// .replace('"input": Event;', '"input": Event & {currentTarget: HTMLInputElement, target: HTMLInputElement};')
29+
// }
30+
// return contents
31+
// }
1532
// const compilerOptions = typescript.convertCompilerOptionsFromJson(options.compilerOptions, options.sourcesRoot).options
1633
// console.log('getCompilationSettings', info.languageServiceHost.getCompilationSettings())
1734
// info.languageServiceHost.getScriptSnapshot

0 commit comments

Comments
 (0)