Skip to content

Commit

Permalink
Merge branch 'master' into typed-slots-improves
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Mar 26, 2023
2 parents 6c61e99 + f1a2e63 commit 7cd49ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export function generate(
writeTemplate();

if (generateFunctionType) {
codeGen.push(`return {} as Omit<JSX.Element, 'props' | 'children'> & Omit<InstanceType<typeof __VLS_publicComponent>, '$slots' | '$emit'>`);
codeGen.push(`return {} as Omit<import('./__VLS_types.js').Element, 'props' | 'children'> & Omit<InstanceType<typeof __VLS_publicComponent>, '$slots' | '$emit'>`);
codeGen.push(` & {\n`);
if (scriptSetupRanges.propsTypeArg) {
codeGen.push(`props: typeof __VLS_props,\n`);
Expand Down
6 changes: 3 additions & 3 deletions packages/vue-language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export function generate(
if (_isIntrinsicElement) {

for (const offset of tagOffsets) {
codeGen.push(`({} as JSX.IntrinsicElements)`);
codeGen.push(`({} as import('./__VLS_types.js').IntrinsicElements)`);
writePropertyAccess(
node.tag,
offset,
Expand All @@ -543,7 +543,7 @@ export function generate(
codeGen.push(`;\n`);
}

codeGen.push(`(__VLS_any as JSX.IntrinsicElements)[`);
codeGen.push(`(__VLS_any as import('./__VLS_types.js').IntrinsicElements)[`);
writeCodeWithQuotes(
node.tag,
tagOffsets[0],
Expand Down Expand Up @@ -699,7 +699,7 @@ export function generate(

codeGen.push(`type ${varInstanceProps} = `);
if (!varComponentInstance) {
codeGen.push(`JSX.IntrinsicElements['${node.tag}'];\n`);
codeGen.push(`import('./__VLS_types.js').IntrinsicElements['${node.tag}'];\n`);
}
else {
codeGen.push(`import('./__VLS_types.js').InstanceProps<typeof ${varComponentInstance}, ${componentVar ? 'typeof __VLS_templateComponents.' + componentVar : '{}'}>;\n`);;
Expand Down
4 changes: 4 additions & 0 deletions packages/vue-language-core/src/utils/localTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import type {
ObjectDirective,
FunctionDirective,
} from '${libName}';
${vueCompilerOptions.target >= 3.3 ? `import { JSX } from 'vue/jsx-runtime';` : ''}
export type IntrinsicElements = JSX.IntrinsicElements;
export type Element = JSX.Element;
type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
export type PickNotAny<A, B> = IsAny<A> extends true ? B : A;
Expand Down

0 comments on commit 7cd49ab

Please sign in to comment.