diff options
| author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2022-12-18 13:13:05 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-18 13:13:05 +0900 |
| commit | bb3d274db64fe662ad01780ca5eadbc263f6f759 (patch) | |
| tree | 2fcd6dfb55cabad77441a6d3cdb2ef5fbec075e2 /packages/client/src/components | |
| parent | Remove redundant ts-node things (#9335) (diff) | |
| download | sharkey-bb3d274db64fe662ad01780ca5eadbc263f6f759.tar.gz sharkey-bb3d274db64fe662ad01780ca5eadbc263f6f759.tar.bz2 sharkey-bb3d274db64fe662ad01780ca5eadbc263f6f759.zip | |
refactor(client): add proper types to `never[]` (#9340)
Diffstat (limited to 'packages/client/src/components')
| -rw-r--r-- | packages/client/src/components/mfm.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/packages/client/src/components/mfm.ts b/packages/client/src/components/mfm.ts index 688857a499..5b5b1caae3 100644 --- a/packages/client/src/components/mfm.ts +++ b/packages/client/src/components/mfm.ts @@ -54,13 +54,13 @@ export default defineComponent({ return t.match(/^[0-9.]+s$/) ? t : null; }; - const genEl = (ast: mfm.MfmNode[]) => concat(ast.map((token): VNode[] => { + const genEl = (ast: mfm.MfmNode[]) => ast.map((token): VNode | string | (VNode | string)[] => { switch (token.type) { case 'text': { const text = token.props.text.replace(/(\r\n|\n|\r)/g, '\n'); if (!this.plain) { - const res = []; + const res: (VNode | string)[] = []; for (const t of text.split('\n')) { res.push(h('br')); res.push(t); @@ -317,12 +317,13 @@ export default defineComponent({ } default: { - console.error('unrecognized ast type:', token.type); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + console.error('unrecognized ast type:', (token as any).type); return []; } } - })); + }).flat(Infinity) as (VNode | string)[]; // Parse ast to DOM return h('span', genEl(ast)); |