Skip to content

Commit

Permalink
WIP: add lib.dom eventTypePatching (disabled by default)
Browse files Browse the repository at this point in the history
fix: crash on start
  • Loading branch information
zardoy committed May 8, 2022
1 parent 3aca612 commit 90d83d0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions buildTsPlugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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']
})
}

Expand Down
4 changes: 4 additions & 0 deletions src/configurationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export type Configuration = {
* @default true
*/
'jsxImproveElementsSuggestions.enabled': boolean
/**
* Requires restart TS server
* @default false
* */
// 'eventTypePatching.enable': boolean
// 'globalTypedQuerySelector.enable': boolean,
/**
Expand Down
2 changes: 1 addition & 1 deletion src/configurationTypeCache.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// GENERATED. DON'T EDIT MANUALLY
// md5hash: ba4b89b4b50869a61ab291839b74492d
// md5hash: 9c3812628516e353f3aa75256e99e8fa
{
"type": "object",
"properties": {
Expand Down
17 changes: 17 additions & 0 deletions typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90d83d0

Please sign in to comment.