Enable Typescript strictFunctionTypes
(#32911)
1. Enable [strictFunctionTypes](https://www.typescriptlang.org/tsconfig/#strictFunctionTypes) 2. Introduce `DOMEvent` helper type which sets `e.target`. Surely not totally correct with that `Partial` but seems to work. 3. Various type-related refactors, change objects in `eventsource.sharedworker.ts` to `Map`.
This commit is contained in:
parent
09a0041965
commit
c0e80dbe26
21 changed files with 94 additions and 84 deletions
|
@ -12,7 +12,7 @@ type ProcessorContext = {
|
|||
|
||||
function prepareProcessors(ctx:ProcessorContext): Processors {
|
||||
const processors = {
|
||||
H1(el: HTMLHeadingElement) {
|
||||
H1(el: HTMLElement) {
|
||||
const level = parseInt(el.tagName.slice(1));
|
||||
el.textContent = `${'#'.repeat(level)} ${el.textContent.trim()}`;
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ function prepareProcessors(ctx:ProcessorContext): Processors {
|
|||
DEL(el: HTMLElement) {
|
||||
return `~~${el.textContent}~~`;
|
||||
},
|
||||
A(el: HTMLAnchorElement) {
|
||||
A(el: HTMLElement) {
|
||||
const text = el.textContent || 'link';
|
||||
const href = el.getAttribute('href');
|
||||
if (/^https?:/.test(text) && text === href) {
|
||||
|
@ -33,7 +33,7 @@ function prepareProcessors(ctx:ProcessorContext): Processors {
|
|||
}
|
||||
return href ? `[${text}](${href})` : text;
|
||||
},
|
||||
IMG(el: HTMLImageElement) {
|
||||
IMG(el: HTMLElement) {
|
||||
const alt = el.getAttribute('alt') || 'image';
|
||||
const src = el.getAttribute('src');
|
||||
const widthAttr = el.hasAttribute('width') ? ` width="${htmlEscape(el.getAttribute('width') || '')}"` : '';
|
||||
|
@ -43,7 +43,7 @@ function prepareProcessors(ctx:ProcessorContext): Processors {
|
|||
}
|
||||
return ``;
|
||||
},
|
||||
P(el: HTMLParagraphElement) {
|
||||
P(el: HTMLElement) {
|
||||
el.textContent = `${el.textContent}\n`;
|
||||
},
|
||||
BLOCKQUOTE(el: HTMLElement) {
|
||||
|
@ -54,14 +54,14 @@ function prepareProcessors(ctx:ProcessorContext): Processors {
|
|||
el.textContent = `${preNewLine}${el.textContent}\n`;
|
||||
},
|
||||
LI(el: HTMLElement) {
|
||||
const parent = el.parentNode;
|
||||
const bullet = (parent as HTMLElement).tagName === 'OL' ? `1. ` : '* ';
|
||||
const parent = el.parentNode as HTMLElement;
|
||||
const bullet = parent.tagName === 'OL' ? `1. ` : '* ';
|
||||
const nestingIdentLevel = Math.max(0, ctx.listNestingLevel - 1);
|
||||
el.textContent = `${' '.repeat(nestingIdentLevel * 4)}${bullet}${el.textContent}${ctx.elementIsLast ? '' : '\n'}`;
|
||||
return el;
|
||||
},
|
||||
INPUT(el: HTMLInputElement) {
|
||||
return el.checked ? '[x] ' : '[ ] ';
|
||||
INPUT(el: HTMLElement) {
|
||||
return (el as HTMLInputElement).checked ? '[x] ' : '[ ] ';
|
||||
},
|
||||
CODE(el: HTMLElement) {
|
||||
const text = el.textContent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue