Skip to content

Commit

Permalink
Merge branch 'main' into feat/upgrade-volar2
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Jun 11, 2024
2 parents 785e0de + 7a2b1ac commit 59e061c
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"packageManager": "pnpm@9.2.0",
"scripts": {
"typecheck": "tsc --noEmit",
"typecheck": "tsc",
"build": "pnpm -r run build",
"test": "vitest",
"lint": "eslint .",
Expand Down
2 changes: 1 addition & 1 deletion packages/twoslash-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export function createTwoslasher(createOptions: CreateTwoslashVueOptions = {}):
...sourceMeta.removals,
...result.meta.removals
.map((r) => {
const start = [...map.getSourceOffsets(r[0])][0]?.[0]
const start = [...map.getSourceOffsets(r[0])][0]?.[0] ?? code.match(/(?<=<script[\s\S]*>\s)/)?.index
const end = [...map.getSourceOffsets(r[1])][0]?.[0]
if (start == null || end == null || start < 0 || end < 0 || start >= end)
return undefined
Expand Down
23 changes: 23 additions & 0 deletions packages/twoslash-vue/test/fixtures/cut-around-vue.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { ref } from "vue"
// ---cut-before---
interface Foo {
bar: string
}
// ---cut---
const { hi } = useFoo()
function useFoo() {
const hi = ref<Foo>({ bar: "hello" })
return { hi }
}
// ---cut-after---
declare const foo: {
hi: string
}
</script>

<template>
<div>
{{ hi.bar }}
</div>
</template>
89 changes: 89 additions & 0 deletions packages/twoslash-vue/test/results/cut-around-vue.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"moduleDetection": "force",
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"paths": {
"twoslash": [
"./packages/twoslash/src/index.ts"
Expand All @@ -30,6 +30,7 @@
],
"allowJs": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"isolatedModules": true,
"skipDefaultLibCheck": true,
Expand Down

0 comments on commit 59e061c

Please sign in to comment.