Skip to content

Commit 18b634d

Browse files
authored
feat(twoslash-vue): upgrade @vue/language-core to 3.0 (#71)
1 parent 1ca03da commit 18b634d

File tree

8 files changed

+201
-42
lines changed

8 files changed

+201
-42
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default defineConfig({
3939
title: 'Twoslash',
4040
description: 'Markup for TypeScript information in docs',
4141
markdown: {
42+
languages: ['vue'],
4243
theme: {
4344
light: 'vitesse-light',
4445
dark: 'vitesse-dark',

packages/twoslash-vue/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import type {
1212
import type { CompilerOptions } from 'typescript'
1313
import {
1414
createLanguage,
15+
createParsedCommandLineByJson,
1516
createVueLanguagePlugin,
1617
defaultMapperFactory,
1718
FileMap,
18-
resolveVueCompilerOptions,
19-
setupGlobalTypes,
2019
} from '@vue/language-core'
2120
import {
2221
createTwoslasher as createTwoslasherBase,
@@ -72,9 +71,11 @@ export function createTwoslasher(createOptions: CreateTwoslashVueOptions = {}):
7271
return cache.get(key)!
7372

7473
function getLanguage() {
75-
const resolvedVueOptions = resolveVueCompilerOptions(vueCompilerOptions)
76-
resolvedVueOptions.__setupedGlobalTypes = setupGlobalTypes(ts.sys.getCurrentDirectory(), resolvedVueOptions, ts.sys)
77-
const vueLanguagePlugin = createVueLanguagePlugin<string>(ts, defaultCompilerOptions, resolvedVueOptions, id => id)
74+
const vueOptions = {
75+
...createParsedCommandLineByJson(ts, ts.sys, ts.sys.getCurrentDirectory(), {}).vueOptions,
76+
...vueCompilerOptions,
77+
}
78+
const vueLanguagePlugin = createVueLanguagePlugin<string>(ts, defaultCompilerOptions, vueOptions, id => id)
7879
return createLanguage(
7980
[vueLanguagePlugin],
8081
new FileMap(ts.sys.useCaseSensitiveFileNames) as unknown as Map<string, SourceScript<string>>,

packages/twoslash-vue/test/query.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ describe('basic', () => {
3030

3131
expect(result.meta.positionQueries)
3232
.toMatchInlineSnapshot(`
33-
[
34-
93,
35-
161,
36-
863,
37-
1034,
38-
]
39-
`)
33+
[
34+
93,
35+
161,
36+
898,
37+
1099,
38+
]
39+
`)
4040

4141
expect(result.nodes.find(n => n.type === 'query' && n.target === 'computed'))
4242
.toMatchInlineSnapshot(`

packages/twoslash-vue/test/results/completion.json

Lines changed: 134 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)