Skip to content

Commit 52384e2

Browse files
committed
✨ refactor: remove all @ts-* directives
1 parent f150771 commit 52384e2

File tree

7 files changed

+106
-232
lines changed

7 files changed

+106
-232
lines changed

components/blog/Layout.vue

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
</p>
2121
</div>
2222
</aside> -->
23-
<img
24-
:src="props.src"
25-
:alt="props.alt"
26-
class="w-full my-6"
27-
:class="props.shadow ? 'shadow-xl' : 'border'"
28-
/>
23+
<img :src="props.src" :alt="props.alt" class="w-full my-6" :class="props.shadow ? 'shadow-xl' : 'border'" />
2924
<main id="blog-content">
3025
<slot />
3126
</main>
@@ -64,14 +59,12 @@ onMounted(() => {
6459
mutated.forEach((selector) => {
6560
console.log(document.querySelector(selector))
6661
67-
// @ts-ignore
6862
document.querySelector(selector)?.classList.add('blog')
6963
})
7064
})
7165
7266
onUnmounted(() => {
7367
mutated.forEach((selector) => {
74-
// @ts-ignore
7568
document.querySelector(selector)?.classList.remove('blog')
7669
})
7770
})
@@ -97,26 +90,26 @@ onUnmounted(() => {
9790
@apply text-lg mt-0;
9891
}
9992
100-
#blog > img {
93+
#blog>img {
10194
@apply rounded-lg;
10295
}
10396
104-
#blog > h1 {
97+
#blog>h1 {
10598
@apply !text-3xl md:!text-4xl font-semibold;
10699
}
107100
108-
#blog > h2 {
101+
#blog>h2 {
109102
@apply !text-2xl md:!text-3xl font-semibold;
110103
}
111104
112-
#blog > h3 {
105+
#blog>h3 {
113106
@apply !text-xl md:!text-2xl font-semibold;
114107
}
115108
116-
#blog-content > video,
117-
#blog-content > * > video,
118-
#blog-content > img,
119-
#blog-content > * > img {
109+
#blog-content>video,
110+
#blog-content>*>video,
111+
#blog-content>img,
112+
#blog-content>*>img {
120113
@apply rounded-xl my-4;
121114
/* box-shadow: 0 8px 25px rgba(0,0,0,.1) */
122115
}
@@ -127,7 +120,7 @@ onUnmounted(() => {
127120
}
128121
129122
@media (min-width: 768px) {
130-
#blog > h1 {
123+
#blog>h1 {
131124
line-height: 3.25rem !important;
132125
}
133126
}

components/midori/editor.vue

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<script setup lang="ts">
22
import { onMounted, ref } from 'vue'
33
import Prism from 'vue-prism-component'
4-
// @ts-ignore
54
import PrismJS from 'prismjs';
65
const { highlight, languages } = PrismJS
76
87
import { Elysia } from 'elysia'
9-
import { text } from 'stream/consumers'
108
119
let code = `const app = new Elysia()
1210
.get('/', () => 'Hello!')
@@ -18,7 +16,6 @@ export default app
1816
`
1917
2018
function saveCaretPosition(context) {
21-
// @ts-ignore
2219
const selection = window.getSelection()
2320
const range = selection.getRangeAt(0)
2421
range.setStart(context, 0)
@@ -28,15 +25,13 @@ function saveCaretPosition(context) {
2825
const pos = getTextNodeAtPosition(context, len)
2926
selection.removeAllRanges()
3027
31-
// @ts-ignore
3228
const range = new Range()
3329
range.setStart(pos.node, pos.position)
3430
selection.addRange(range)
3531
}
3632
}
3733
3834
function nextCaretPosition(context) {
39-
// @ts-ignore
4035
const selection = window.getSelection()
4136
const range = selection.getRangeAt(0)
4237
range.setStart(context, 0)
@@ -46,28 +41,23 @@ function nextCaretPosition(context) {
4641
const pos = getTextNodeAtPosition(context, len)
4742
selection.removeAllRanges()
4843
49-
// @ts-ignore
5044
const range = new Range()
5145
range.setStart(pos.node, pos.position)
5246
selection.addRange(range)
5347
}
5448
}
5549
5650
function getTextNodeAtPosition(root, index) {
57-
// @ts-ignore
5851
const NODE_TYPE = NodeFilter.SHOW_TEXT
59-
// @ts-ignore
6052
const treeWalker = document.createTreeWalker(
6153
root,
6254
NODE_TYPE,
6355
function next(elem) {
6456
if (index > elem.textContent.length) {
6557
index -= elem.textContent.length
66-
// @ts-ignore
6758
return NodeFilter.FILTER_REJECT
6859
}
6960
70-
// @ts-ignore
7161
return NodeFilter.FILTER_ACCEPT
7262
}
7363
)
@@ -84,7 +74,7 @@ let response = ref('Hello from Elysia!')
8474
8575
let instance = new Elysia()
8676
.get('/', () => 'Hello!')
87-
.get('/hello', () => 'Hello from Elysia!')
77+
.get('/hello', () => 'Hello from Elysia!') as Elysia<any, any>
8878
8979
let editorError = ref(undefined as Error | undefined)
9080
let responseError = ref(undefined as Error | undefined)
@@ -113,8 +103,7 @@ const execute = async () => {
113103
}
114104
115105
onMounted(() => {
116-
// @ts-ignore
117-
const editor = document.querySelector('pre.elysia-editor')
106+
const editor = document.querySelector<HTMLElement>('pre.elysia-editor')
118107
119108
function rehighlight(event) {
120109
const restore = saveCaretPosition(this)
@@ -135,6 +124,7 @@ onMounted(() => {
135124
'export default is missing'
136125
))
137126
127+
138128
instance = new Function(
139129
'Elysia',
140130
`
@@ -165,63 +155,46 @@ onMounted(() => {
165155
</script>
166156

167157
<template>
168-
<article
169-
class="flex flex-col justify-center items-center w-full max-w-6xl mx-auto mt-6 md:my-12"
170-
>
158+
<article class="flex flex-col justify-center items-center w-full max-w-6xl mx-auto mt-6 md:my-12">
171159
<h2
172-
class="text-6xl w-full text-left sm:text-center font-bold !leading-tight text-transparent bg-clip-text bg-gradient-to-br from-blue-400 to-violet-400 mb-6"
173-
>
160+
class="text-6xl w-full text-left sm:text-center font-bold !leading-tight text-transparent bg-clip-text bg-gradient-to-br from-blue-400 to-violet-400 mb-6">
174161
Try it out
175162
</h2>
176163

177-
<p
178-
class="text-xl md:text-2xl leading-relaxed text-gray-400 text-left md:text-center w-full max-w-2xl"
179-
>
164+
<p class="text-xl md:text-2xl leading-relaxed text-gray-400 text-left md:text-center w-full max-w-2xl">
180165
Being WinterCG compliant, Elysia can run in your browser!
181166
<br />
182167
Edit the code and see live update immediately.
183168
</p>
184169

185170
<aside class="flex flex-col md:flex-row justify-center items-center w-full max-w-6xl gap-8 my-8">
186-
<section
187-
class="flex flex-col w-full h-96 border dark:border-slate-700 bg-white dark:bg-slate-800 rounded-2xl"
188-
>
171+
<section class="flex flex-col w-full h-96 border dark:border-slate-700 bg-white dark:bg-slate-800 rounded-2xl">
189172
<div class="mockup-window flex relative w-full h-full shadow-xl">
190173
<Prism
191174
class="elysia-editor block !bg-transparent !text-base !font-mono rounded-xl w-full max-w-xl h-full !pt-0 !px-2 outline-none"
192-
language="typescript"
193-
contenteditable="true"
194-
>
175+
language="typescript" contenteditable="true">
195176
{{ code }}
196177
</Prism>
197178

198-
<footer
199-
v-if="editorError"
200-
class="absolute bottom-0 flex flex-col w-full max-h-40 overflow-y-auto text-white font-medium px-4 py-2 bg-red-500"
201-
>
179+
<footer v-if="editorError"
180+
class="absolute bottom-0 flex flex-col w-full max-h-40 overflow-y-auto text-white font-medium px-4 py-2 bg-red-500">
202181
{{ editorError.cause }}
203182
{{ editorError.stack }}
204183
</footer>
205184
</div>
206185
</section>
207-
<div class="w-full mockup-browser h-96 shadow-xl border dark:border-slate-700 bg-white dark:bg-slate-800 max-w-full">
186+
<div
187+
class="w-full mockup-browser h-96 shadow-xl border dark:border-slate-700 bg-white dark:bg-slate-800 max-w-full">
208188
<div class="mockup-browser-toolbar">
209189
<form class="input font-medium !bg-gray-100 dark:!bg-slate-700" @submit.prevent="execute">
210190
<span class="text-gray-400 dark:text-gray-300">localhost</span>
211-
<input
212-
class="absolute"
213-
type="text"
214-
v-model="url"
215-
v-on:blur="execute"
216-
/>
191+
<input class="absolute" type="text" v-model="url" v-on:blur="execute" />
217192
</form>
218193
</div>
219194
<div class="flex px-4">{{ response }}</div>
220195

221-
<footer
222-
v-if="responseError"
223-
class="absolute bottom-0 flex flex-col w-full max-h-40 overflow-y-auto text-white font-medium px-4 py-2 bg-red-500"
224-
>
196+
<footer v-if="responseError"
197+
class="absolute bottom-0 flex flex-col w-full max-h-40 overflow-y-auto text-white font-medium px-4 py-2 bg-red-500">
225198
{{ responseError.cause }}
226199
{{ responseError.stack }}
227200
</footer>

0 commit comments

Comments
 (0)