Skip to content

Commit d1fecb1

Browse files
committed
fix: type errors
1 parent 97cf6cd commit d1fecb1

13 files changed

Lines changed: 23 additions & 27 deletions

File tree

demo/composable-vue/setup/monaco.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineMonacoSetup } from '@slidev/types'
22

33
export default defineMonacoSetup((monaco) => {
4-
monaco.languages.typescript.typescriptDefaults.addExtraLib(
4+
monaco.typescript.typescriptDefaults.addExtraLib(
55
`
66
import { InjectionKey } from 'vue'
77
export interface UserInfo { id: number; name: string }

packages/client/builtin/Link.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const { isPrintMode } = useNav()
1919
</script>
2020

2121
<template>
22-
<RouterLink v-if="!isPrintMode && title" :to="String(to)" @click="$event.target.blur()" v-html="title" />
23-
<RouterLink v-else-if="!isPrintMode && !title" :to="String(to)" @click="$event.target.blur()">
22+
<RouterLink v-if="!isPrintMode && title" :to="String(to)" @click="($event.target as HTMLElement)?.blur()" v-html="title" />
23+
<RouterLink v-else-if="!isPrintMode && !title" :to="String(to)" @click="($event.target as HTMLElement)?.blur()">
2424
<slot />
2525
</RouterLink>
2626
<a v-else-if="isPrintMode && title" :href="`#${to}`" v-html="title" />

packages/client/builtin/Monaco.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ const extMap: Record<string, string> = {
7272
}
7373
const ext = extMap[props.lang] ?? props.lang
7474
75-
const outer = ref<HTMLDivElement>()
7675
const container = ref<HTMLDivElement>()
7776
7877
const contentHeight = ref(0)
@@ -206,7 +205,7 @@ onMounted(async () => {
206205

207206
<template>
208207
<div class="relative slidev-monaco-container">
209-
<div ref="outer" class="relative slidev-monaco-container-inner" :style="{ height }">
208+
<div class="relative slidev-monaco-container-inner" :style="{ height }">
210209
<div ref="container" class="absolute inset-0.5" />
211210
</div>
212211
<CodeRunner

packages/client/builtin/VDrag.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const props = defineProps<{
88
markdownSource?: DragElementMarkdownSource
99
}>()
1010
11+
// @ts-expect-error TS6133 container is used as template ref
1112
const { dragId, container, containerStyle, mounted, unmounted, startDragging } = useDragElement(null, props.pos, props.markdownSource)
1213
1314
onMounted(mounted)

packages/client/composables/useDrawings.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Brush, Options as DrauuOptions, DrawingMode } from 'drauu'
2-
import { createSharedComposable, toReactive, useLocalStorage } from '@vueuse/core'
2+
import { createSharedComposable, useLocalStorage } from '@vueuse/core'
33
import { createDrauu } from 'drauu'
44
import { computed, markRaw, nextTick, reactive, ref, watch } from 'vue'
55
import { configs } from '../env'
@@ -22,11 +22,11 @@ export const useDrawings = createSharedComposable(() => {
2222

2323
const drawingEnabled = useLocalStorage('slidev-drawing-enabled', false)
2424
const drawingPinned = useLocalStorage('slidev-drawing-pinned', false)
25-
const brush = toReactive(useLocalStorage<Brush>('slidev-drawing-brush', {
25+
const brush = useLocalStorage<Brush>('slidev-drawing-brush', {
2626
color: brushColors[0],
2727
size: 4,
2828
mode: 'stylus',
29-
}))
29+
})
3030

3131
const isDrawing = ref(false)
3232
const canUndo = ref(false)
@@ -46,12 +46,12 @@ export const useDrawings = createSharedComposable(() => {
4646
if (v === 'arrow') {
4747
// eslint-disable-next-line ts/no-use-before-define
4848
drauu.mode = 'line'
49-
brush.arrowEnd = true
49+
brush.value.arrowEnd = true
5050
}
5151
else {
5252
// eslint-disable-next-line ts/no-use-before-define
5353
drauu.mode = v
54-
brush.arrowEnd = false
54+
brush.value.arrowEnd = false
5555
}
5656
},
5757
})
@@ -150,7 +150,7 @@ export const useDrawings = createSharedComposable(() => {
150150
clearDrauu()
151151
}
152152
else if (e.code.startsWith('Digit') && noModifier && +e.code[5] <= brushColors.length) {
153-
brush.color = brushColors[+e.code[5] - 1]
153+
brush.value.color = brushColors[+e.code[5] - 1]
154154
}
155155
else {
156156
handled = false

packages/client/composables/useSlideInfo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { SlideInfo, SlidePatch } from '@slidev/types'
2-
import type { MaybeRef } from '@vueuse/core'
3-
import type { Ref } from 'vue'
2+
import type { MaybeRef, Ref } from 'vue'
43
import { useFetch } from '@vueuse/core'
54
import { computed, ref, unref } from 'vue'
65
import { getSlide } from '../logic/slides'

packages/client/internals/DrawingControls.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function setDrawingMode(mode: typeof drawingMode.value) {
3232
if (mode !== 'eraseLine')
3333
lastDrawingMode = mode
3434
}
35-
function setBrushColor(color: typeof brush.color) {
36-
brush.color = color
35+
function setBrushColor(color: string) {
36+
brush.value.color = color
3737
drawingEnabled.value = true
3838
drawingMode.value = lastDrawingMode
3939
}

packages/client/internals/ShikiEditor.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref, shallowRef } from 'vue'
2+
import { shallowRef } from 'vue'
33
import { useIME } from '../composables/useIME'
44
55
const props = defineProps<{
@@ -8,8 +8,6 @@ const props = defineProps<{
88
const content = defineModel<string>({ required: true })
99
const { composingContent, onInput, onCompositionEnd } = useIME(content)
1010
11-
const textareaEl = ref<HTMLTextAreaElement | null>(null)
12-
1311
const highlight = shallowRef<((code: string) => string) | null>(null)
1412
import('../setup/shiki').then(async (m) => {
1513
const { getEagerHighlighter, defaultHighlightOptions } = await m.default()
@@ -26,7 +24,7 @@ import('../setup/shiki').then(async (m) => {
2624
<div v-if="highlight" class="relative w-full h-max min-h-full">
2725
<div class="relative w-full h-max" v-html="`${highlight(composingContent)}&nbsp;`" />
2826
<textarea
29-
ref="textareaEl" v-model="composingContent" :placeholder="props.placeholder"
27+
v-model="composingContent" :placeholder="props.placeholder"
3028
class="absolute inset-0 resize-none text-transparent bg-transparent focus:outline-none caret-black dark:caret-white overflow-y-hidden"
3129
@input="onInput"
3230
@compositionend="onCompositionEnd"

packages/client/pages/export.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async function pngsGz() {
161161
})),
162162
)
163163
const a = document.createElement('a')
164-
const blob = new Blob([data], { type: 'application/gzip' })
164+
const blob = new Blob([data as any], { type: 'application/gzip' })
165165
a.href = URL.createObjectURL(blob)
166166
a.download = `${title.value}.tar.gz`
167167
a.click()

packages/client/setup/monaco.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ StandaloneServices.initialize({
5656
})
5757

5858
const setup = createSingletonPromise(async () => {
59-
const defaults = monaco.languages.typescript.typescriptDefaults
59+
const defaults = monaco.typescript.typescriptDefaults
6060
defaults.setCompilerOptions({
6161
...defaults.getCompilerOptions(),
6262
strict: true,
63-
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
64-
module: monaco.languages.typescript.ModuleKind.ESNext,
63+
moduleResolution: monaco.typescript.ModuleResolutionKind.NodeJs,
64+
module: monaco.typescript.ModuleKind.ESNext,
6565
})
6666

6767
const ata = configs.monacoTypesSource === 'cdn'
@@ -137,7 +137,7 @@ const setup = createSingletonPromise(async () => {
137137
async function _addFile(raw: () => Promise<{ default: string }>, path: string) {
138138
const uri = monaco.Uri.file(path)
139139
const code = (await raw()).default
140-
monaco.languages.typescript.typescriptDefaults.addExtraLib(code, `file:///${path}`)
140+
monaco.typescript.typescriptDefaults.addExtraLib(code, `file:///${path}`)
141141
monaco.editor.createModel(code, 'javascript', uri)
142142
}
143143

0 commit comments

Comments
 (0)