Skip to content

Commit

Permalink
fix(component-meta): fix modules interoperability with `vue-component…
Browse files Browse the repository at this point in the history
…-type-helper`

close #3566
  • Loading branch information
johnsoncodehk committed Sep 19, 2023
1 parent 323938b commit f33face
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/vue-component-meta/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vue from '@vue/language-core';
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as path from 'typesafe-path/posix';
import typeHelpersCode from 'vue-component-type-helpers';
import { code as typeHelpersCode } from 'vue-component-type-helpers';
import { createLanguageServiceHost, decorateLanguageService } from '@volar/typescript';

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-component-meta/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import { describe, expect, test } from 'vitest';
import { createComponentMetaChecker, createComponentMetaCheckerByJsonConfig, MetaCheckerOptions, ComponentMetaChecker, TypeMeta } from '../src';
import { createComponentMetaChecker, createComponentMetaCheckerByJsonConfig, MetaCheckerOptions, ComponentMetaChecker, TypeMeta } from '../out';

const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describe(`vue-component-meta ${withTsconfig ? 'with tsconfig' : 'without tsconfig'}`, () => {

Expand Down
4 changes: 2 additions & 2 deletions packages/vue-component-type-helpers/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare const text: string;
export declare const code: string;

export default text;
export default code;

export type ComponentType<T> =
T extends new () => {} ? 1 :
Expand Down
5 changes: 4 additions & 1 deletion packages/vue-component-type-helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.default = `
const code = `
export type ComponentType<T> =
T extends new () => {} ? 1 :
T extends (...args: any) => any ? 2 :
Expand Down Expand Up @@ -33,3 +33,6 @@ export type Vue2ComponentSlots<T> =
T extends (props: any, ctx: { slots: infer S; }, ...args: any) => any ? NonNullable<S> :
{};
`.trim();

exports.code = code;
exports.default = code;
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/utils/createTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs';
import * as path from 'path';
import type * as ts from 'typescript/lib/tsserverlibrary';
import { URI } from 'vscode-uri';
import { resolveConfig } from '../../src';
import { resolveConfig } from '../../out';

const uriToFileName = (uri: string) => URI.parse(uri).fsPath.replace(/\\/g, '/');
const fileNameToUri = (fileName: string) => URI.file(fileName).toString();
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/utils/format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import * as kit from '@volar/kit';
import { resolveConfig } from '../../src';
import { resolveConfig } from '../../out';

const formatter = kit.createFormatter(resolveConfig({}));

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-tsc/tests/dts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import * as fs from 'fs';
import * as ts from 'typescript';
import { describe, expect, it } from 'vitest';
import { createProgram } from '../src';
import { createProgram } from '../out';

const workspace = path.resolve(__dirname, '../../vue-test-workspace/vue-tsc-dts');
const testFiles = readFilesRecursive(workspace);
Expand Down

0 comments on commit f33face

Please sign in to comment.