@vue/language-core
Advanced tools
Comparing version 2.1.2 to 2.1.4
@@ -1,1 +0,1 @@ | ||
export declare function generateGlobalTypes(lib: string, target: number, strictTemplates: boolean): string; | ||
export declare function generateGlobalTypes(mode: 'global' | 'local', lib: string, target: number, strictTemplates: boolean): string; |
@@ -5,10 +5,24 @@ "use strict"; | ||
const shared_1 = require("../utils/shared"); | ||
function generateGlobalTypes(lib, target, strictTemplates) { | ||
const common_1 = require("./common"); | ||
function generateGlobalTypes(mode, lib, target, strictTemplates) { | ||
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${strictTemplates ? '' : ' & Record<string, unknown>'}`; | ||
return ` | ||
const __VLS_globalComponents = { ...{} as import('${lib}').GlobalComponents }; | ||
let str = ''; | ||
let globalComponentsType; | ||
if (mode === 'global') { | ||
str += `// @ts-nocheck${common_1.newLine}`; | ||
str += `export {}${common_1.endOfLine}`; | ||
str += `declare module '${lib}' {${common_1.newLine}`; | ||
str += ` export interface GlobalComponents { }${common_1.newLine}`; | ||
str += `}${common_1.newLine}`; | ||
str += `declare global {${common_1.newLine}`; | ||
globalComponentsType = `import('${lib}').GlobalComponents`; | ||
} | ||
else { | ||
str += `const __VLS_globalComponents = { ...{} as import('${lib}').GlobalComponents }${common_1.endOfLine}`; | ||
globalComponentsType = `void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents`; | ||
} | ||
str += ` | ||
const __VLS_intrinsicElements: __VLS_IntrinsicElements; | ||
const __VLS_directiveBindingRestFields = { instance: null, oldValue: null, modifiers: null as any, dir: null as any }; | ||
declare const __VLS_intrinsicElements: __VLS_IntrinsicElements; | ||
declare const __VLS_directiveBindingRestFields = { instance: null, oldValue: null, modifiers: null as any, dir: null as any }; | ||
type __VLS_IntrinsicElements = ${(target >= 3.3 | ||
@@ -21,4 +35,4 @@ ? `import('${lib}/jsx-runtime').JSX.IntrinsicElements;` | ||
type __VLS_GlobalComponents = ${(target >= 3.5 | ||
? `void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents;` | ||
: `(void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents) & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`)} | ||
? globalComponentsType | ||
: `(${globalComponentsType}) & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`)} | ||
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; | ||
@@ -71,5 +85,5 @@ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A; | ||
declare function __VLS_getVForSourceType(source: number): [number, number, number][]; | ||
declare function __VLS_getVForSourceType(source: string): [string, number, number][]; | ||
declare function __VLS_getVForSourceType<T extends any[]>(source: T): [ | ||
function __VLS_getVForSourceType(source: number): [number, number, number][]; | ||
function __VLS_getVForSourceType(source: string): [string, number, number][]; | ||
function __VLS_getVForSourceType<T extends any[]>(source: T): [ | ||
item: T[number], | ||
@@ -79,3 +93,3 @@ key: number, | ||
][]; | ||
declare function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [ | ||
function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [ | ||
item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never, | ||
@@ -86,3 +100,3 @@ key: number, | ||
// #3845 | ||
declare function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [ | ||
function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [ | ||
item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never), | ||
@@ -92,3 +106,3 @@ key: number, | ||
][]; | ||
declare function __VLS_getVForSourceType<T>(source: T): [ | ||
function __VLS_getVForSourceType<T>(source: T): [ | ||
item: T[keyof T], | ||
@@ -99,12 +113,12 @@ key: keyof T, | ||
// @ts-ignore | ||
declare function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>; | ||
function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>; | ||
// @ts-ignore | ||
declare function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0]; | ||
declare function __VLS_directiveAsFunction<T extends import('${lib}').Directive>(dir: T): T extends (...args: any) => any | ||
function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0]; | ||
function __VLS_directiveAsFunction<T extends import('${lib}').Directive>(dir: T): T extends (...args: any) => any | ||
? T | __VLS_unknownDirective | ||
: NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>; | ||
declare function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K; | ||
declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] }; | ||
declare function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T; | ||
declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): | ||
function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K; | ||
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] }; | ||
function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T; | ||
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): | ||
T extends new (...args: any) => any | ||
@@ -119,13 +133,17 @@ ? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: { | ||
: (_: {}${strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${strictTemplates ? '' : ' & Record<string, unknown>'} } }; | ||
declare function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${strictTemplates ? '' : ' & Record<string, unknown>'}) => void; | ||
declare function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : []; | ||
declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny< | ||
function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${strictTemplates ? '' : ' & Record<string, unknown>'}) => void; | ||
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : []; | ||
function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny< | ||
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any | ||
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any | ||
>>; | ||
declare function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S; | ||
declare function __VLS_tryAsConstant<const T>(t: T): T; | ||
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S; | ||
function __VLS_tryAsConstant<const T>(t: T): T; | ||
`; | ||
if (mode === 'global') { | ||
str += `}${common_1.newLine}`; | ||
} | ||
return str; | ||
} | ||
; | ||
//# sourceMappingURL=globalTypes.js.map |
@@ -13,3 +13,2 @@ import type * as ts from 'typescript'; | ||
readonly OmitIndexSignature: string; | ||
readonly PickRefsExpose: string; | ||
}; |
@@ -61,11 +61,2 @@ "use strict"; | ||
const OmitIndexSignature = defineHelper(`__VLS_OmitIndexSignature`, () => `type __VLS_OmitIndexSignature<T> = { [K in keyof T as {} extends Record<K, unknown> ? never : K]: T[K]; }${common_1.endOfLine}`); | ||
const PickRefsExpose = defineHelper(`__VLS_PickRefsExpose`, () => ` | ||
type __VLS_PickRefsExpose<T> = T extends object | ||
? { [K in keyof T]: (T[K] extends any[] | ||
? Parameters<T[K][0]['expose']>[0][] | ||
: T[K] extends { expose?: (exposed: infer E) => void } | ||
? E | ||
: T[K]) | null } | ||
: never; | ||
`.trimStart()); | ||
const helpers = { | ||
@@ -79,3 +70,2 @@ [PrettifyLocal.name]: PrettifyLocal, | ||
[OmitIndexSignature.name]: OmitIndexSignature, | ||
[PickRefsExpose.name]: PickRefsExpose, | ||
}; | ||
@@ -95,3 +85,2 @@ used.clear(); | ||
get OmitIndexSignature() { return OmitIndexSignature.name; }, | ||
get PickRefsExpose() { return PickRefsExpose.name; }, | ||
}; | ||
@@ -98,0 +87,0 @@ function* generate(names) { |
@@ -26,5 +26,4 @@ import { InlayHintInfo } from '../types'; | ||
readonly OmitIndexSignature: string; | ||
readonly PickRefsExpose: string; | ||
}; | ||
inlayHints: InlayHintInfo[]; | ||
}; |
@@ -10,2 +10,3 @@ "use strict"; | ||
const template_1 = require("./template"); | ||
const globalTypes_1 = require("../globalTypes"); | ||
exports.codeFeatures = { | ||
@@ -35,3 +36,8 @@ all: { | ||
const ctx = (0, context_1.createScriptCodegenContext)(options); | ||
yield `/// <reference types="${options.vueCompilerOptions.lib}/dist/__globalTypes_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${common_1.newLine}`; | ||
if (options.vueCompilerOptions.__setupedGlobalTypes?.()) { | ||
yield `/// <reference types=".vue-global-types/${options.vueCompilerOptions.lib}_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${common_1.newLine}`; | ||
} | ||
else { | ||
yield `/* placeholder */`; | ||
} | ||
if (options.sfc.script?.src) { | ||
@@ -117,2 +123,5 @@ yield* (0, src_1.generateSrc)(options.sfc.script, options.sfc.script.src); | ||
yield* ctx.localTypes.generate([...ctx.localTypes.getUsedNames()]); | ||
if (!options.vueCompilerOptions.__setupedGlobalTypes?.()) { | ||
yield (0, globalTypes_1.generateGlobalTypes)('local', options.vueCompilerOptions.lib, options.vueCompilerOptions.target, options.vueCompilerOptions.strictTemplates); | ||
} | ||
if (options.sfc.scriptSetup) { | ||
@@ -119,0 +128,0 @@ yield ['', 'scriptSetup', options.sfc.scriptSetup.content.length, exports.codeFeatures.verification]; |
@@ -43,5 +43,2 @@ "use strict"; | ||
yield `},${common_1.newLine}`; // setup() { | ||
if (options.vueCompilerOptions.target >= 3.5) { | ||
yield `__typeRefs: {} as __VLS_Refs,${common_1.newLine}`; | ||
} | ||
if (options.sfc.scriptSetup && options.scriptSetupRanges && !ctx.bypassDefineComponent) { | ||
@@ -48,0 +45,0 @@ const emitOptionCodes = [...(0, component_1.generateEmitsOption)(options, options.sfc.scriptSetup, options.scriptSetupRanges)]; |
@@ -224,3 +224,11 @@ "use strict"; | ||
if (define?.arg) { | ||
setupCodeModifies.push([[`<__VLS_Refs[${scriptSetup.content.slice(define.arg.start, define.arg.end)}], keyof __VLS_Refs>`], define.arg.start - 1, define.arg.start - 1]); | ||
setupCodeModifies.push([ | ||
[ | ||
`<__VLS_Refs[`, | ||
(0, common_1.generateSfcBlockSection)(scriptSetup, define.arg.start, define.arg.end, index_1.codeFeatures.navigation), | ||
`], keyof __VLS_Refs>` | ||
], | ||
define.arg.start - 1, | ||
define.arg.start - 1 | ||
]); | ||
} | ||
@@ -227,0 +235,0 @@ } |
@@ -16,16 +16,54 @@ "use strict"; | ||
function* generateTemplateCtx(options, isClassComponent) { | ||
const types = []; | ||
const baseExps = []; | ||
const extraExps = []; | ||
if (isClassComponent) { | ||
types.push(`typeof this`); | ||
baseExps.push(`this`); | ||
} | ||
else { | ||
types.push(`InstanceType<__VLS_PickNotAny<typeof __VLS_internalComponent, new () => {}>>`); | ||
baseExps.push(`{} as InstanceType<__VLS_PickNotAny<typeof __VLS_internalComponent, new () => {}>>`); | ||
} | ||
if (options.vueCompilerOptions.petiteVueExtensions.some(ext => options.fileBaseName.endsWith(ext))) { | ||
types.push(`typeof globalThis`); | ||
extraExps.push(`globalThis`); | ||
} | ||
if (options.sfc.styles.some(style => style.module)) { | ||
types.push(`__VLS_StyleModules`); | ||
extraExps.push(`{} as __VLS_StyleModules`); | ||
} | ||
yield `let __VLS_ctx!: ${types.join(' & ')}${common_1.endOfLine}`; | ||
if (options.scriptSetupRanges?.templateRefs.length) { | ||
let exp = `{} as import('${options.vueCompilerOptions.lib}').UnwrapRef<{${common_1.newLine}`; | ||
for (const { name } of options.scriptSetupRanges.templateRefs) { | ||
if (name) { | ||
exp += `${name}: typeof ${name}${common_1.newLine}`; | ||
} | ||
} | ||
exp += `}>${common_1.newLine}`; | ||
extraExps.push(exp); | ||
} | ||
yield `const __VLS_ctxBase = `; | ||
if (baseExps.length === 1) { | ||
yield baseExps[0]; | ||
yield common_1.endOfLine; | ||
} | ||
else { | ||
yield `{${common_1.newLine}`; | ||
for (const exp of baseExps) { | ||
yield `...`; | ||
yield exp; | ||
yield `,${common_1.newLine}`; | ||
} | ||
yield `}${common_1.endOfLine}`; | ||
} | ||
yield `const __VLS_ctx = `; | ||
if (extraExps.length === 0) { | ||
yield `__VLS_ctxBase${common_1.endOfLine}`; | ||
} | ||
else { | ||
yield `{${common_1.newLine}`; | ||
yield `...__VLS_ctxBase,${common_1.newLine}`; | ||
for (const exp of extraExps) { | ||
yield `...`; | ||
yield exp; | ||
yield `,${common_1.newLine}`; | ||
} | ||
yield `}${common_1.endOfLine}`; | ||
} | ||
} | ||
@@ -61,5 +99,4 @@ function* generateTemplateComponents(options) { | ||
exps.push(`{} as NonNullable<typeof __VLS_internalComponent extends { components: infer C } ? C : {}>`); | ||
exps.push(`{} as __VLS_GlobalComponents`); | ||
exps.push(`{} as typeof __VLS_ctx`); | ||
yield `const __VLS_components = {${common_1.newLine}`; | ||
exps.push(`__VLS_ctxBase`); | ||
yield `const __VLS_localComponents = {${common_1.newLine}`; | ||
for (const type of exps) { | ||
@@ -71,2 +108,3 @@ yield `...`; | ||
yield `}${common_1.endOfLine}`; | ||
yield `let __VLS_components: typeof __VLS_localComponents & __VLS_GlobalComponents${common_1.endOfLine}`; | ||
} | ||
@@ -82,3 +120,3 @@ function* generateTemplate(options, ctx, isClassComponent) { | ||
yield* generateTemplateComponents(options); | ||
yield* generateTemplateBody(options, ctx, templateCodegenCtx); | ||
yield* generateTemplateBody(options, templateCodegenCtx); | ||
yield* (0, internalComponent_1.generateInternalComponent)(options, ctx, templateCodegenCtx); | ||
@@ -93,3 +131,3 @@ } | ||
} | ||
function* generateTemplateBody(options, ctx, templateCodegenCtx) { | ||
function* generateTemplateBody(options, templateCodegenCtx) { | ||
const firstClasses = new Set(); | ||
@@ -127,3 +165,3 @@ yield `let __VLS_styleScopedClasses!: {}`; | ||
yield `const __VLS_slots = {}${common_1.endOfLine}`; | ||
yield `const __VLS_refs = {}${common_1.endOfLine}`; | ||
yield `const $refs = {}${common_1.endOfLine}`; | ||
yield `const __VLS_inheritedAttrs = {}${common_1.endOfLine}`; | ||
@@ -134,3 +172,3 @@ } | ||
yield `slots: ${options.scriptSetupRanges?.slots.name ?? '__VLS_slots'},${common_1.newLine}`; | ||
yield `refs: __VLS_refs as ${ctx.localTypes.PickRefsExpose}<typeof __VLS_refs>,${common_1.newLine}`; | ||
yield `refs: $refs,${common_1.newLine}`; | ||
yield `attrs: {} as Partial<typeof __VLS_inheritedAttrs>,${common_1.newLine}`; | ||
@@ -137,0 +175,0 @@ yield `}${common_1.endOfLine}`; |
@@ -153,5 +153,14 @@ "use strict"; | ||
} | ||
const refName = yield* generateVScope(options, ctx, node, props); | ||
const [refName, offset] = yield* generateVScope(options, ctx, node, props); | ||
if (refName) { | ||
const varName = ctx.getInternalVariable(); | ||
options.templateRefNames.set(refName, [varName, offset]); | ||
ctx.usedComponentCtxVars.add(var_defineComponentCtx); | ||
yield `var ${varName} = {} as (Parameters<typeof ${var_defineComponentCtx}['expose']>[0] | null)`; | ||
if (node.codegenNode?.type === CompilerDOM.NodeTypes.VNODE_CALL | ||
&& node.codegenNode.props?.type === CompilerDOM.NodeTypes.JS_OBJECT_EXPRESSION | ||
&& node.codegenNode.props.properties.some(({ key }) => key.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && key.content === 'ref_for')) { | ||
yield `[]`; | ||
} | ||
yield `${common_1.endOfLine}`; | ||
} | ||
@@ -180,14 +189,2 @@ const usedComponentEventsVar = yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, var_functionalComponent, var_componentInstance, var_componentEmit, var_componentEvents); | ||
yield `const ${var_defineComponentCtx} = __VLS_pickFunctionalComponentCtx(${var_originalComponent}, ${var_componentInstance})${common_1.endOfLine}`; | ||
if (refName) { | ||
yield `// @ts-ignore${common_1.newLine}`; | ||
if (node.codegenNode?.type === CompilerDOM.NodeTypes.VNODE_CALL | ||
&& node.codegenNode.props?.type === CompilerDOM.NodeTypes.JS_OBJECT_EXPRESSION | ||
&& node.codegenNode.props.properties.find(({ key }) => key.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && key.content === 'ref_for')) { | ||
yield `(${refName} ??= []).push(${var_defineComponentCtx})`; | ||
} | ||
else { | ||
yield `${refName} = ${var_defineComponentCtx}`; | ||
} | ||
yield common_1.endOfLine; | ||
} | ||
} | ||
@@ -214,8 +211,5 @@ } | ||
} | ||
const refName = yield* generateVScope(options, ctx, node, node.props); | ||
const [refName, offset] = yield* generateVScope(options, ctx, node, node.props); | ||
if (refName) { | ||
yield `// @ts-ignore${common_1.newLine}`; | ||
yield `${refName} = __VLS_intrinsicElements`; | ||
yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag); | ||
yield common_1.endOfLine; | ||
options.templateRefNames.set(refName, [`__VLS_intrinsicElements['${node.tag}']`, offset]); | ||
} | ||
@@ -255,3 +249,3 @@ const slotDir = node.props.find(p => p.type === CompilerDOM.NodeTypes.DIRECTIVE && p.name === 'slot'); | ||
yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node); | ||
const refName = yield* generateReferencesForElements(options, ctx, node); // <el ref="foo" /> | ||
const [refName, offset] = yield* generateReferencesForElements(options, ctx, node); // <el ref="foo" /> | ||
yield* generateReferencesForScopedCssClasses(options, ctx, node); | ||
@@ -262,3 +256,3 @@ if (inScope) { | ||
} | ||
return refName; | ||
return [refName, offset]; | ||
} | ||
@@ -381,7 +375,6 @@ function getCanonicalComponentName(tagText) { | ||
} | ||
const refName = CompilerDOM.toValidAssetId(prop.value.content, '_VLS_refs'); | ||
options.templateRefNames.set(prop.value.content, refName); | ||
return refName; | ||
return [content, startOffset]; | ||
} | ||
} | ||
return []; | ||
} | ||
@@ -388,0 +381,0 @@ function* generateReferencesForScopedCssClasses(options, ctx, node) { |
@@ -13,3 +13,3 @@ import * as CompilerDOM from '@vue/compiler-dom'; | ||
edited: boolean; | ||
templateRefNames: Map<string, string>; | ||
templateRefNames: Map<string, [varName: string, offset: number]>; | ||
hasDefineSlots?: boolean; | ||
@@ -16,0 +16,0 @@ slotsAssignName?: string; |
@@ -10,2 +10,3 @@ "use strict"; | ||
const objectProperty_1 = require("./objectProperty"); | ||
const stringLiteralKey_1 = require("./stringLiteralKey"); | ||
const templateChild_1 = require("./templateChild"); | ||
@@ -21,2 +22,3 @@ const styleScopedClasses_1 = require("./styleScopedClasses"); | ||
} | ||
ctx.addLocalVariable('$refs'); | ||
yield* generatePreResolveComponents(); | ||
@@ -37,10 +39,9 @@ if (options.template.ast) { | ||
function* generateRefs() { | ||
for (const [, validId] of options.templateRefNames) { | ||
yield `let ${validId}${common_1.newLine}`; | ||
} | ||
yield `const __VLS_refs = {${common_1.newLine}`; | ||
for (const [name, validId] of options.templateRefNames) { | ||
yield `'${name}': ${validId}!,${common_1.newLine}`; | ||
for (const [name, [varName, offset]] of options.templateRefNames) { | ||
yield* (0, stringLiteralKey_1.generateStringLiteralKey)(name, offset, ctx.codeFeatures.navigationAndCompletion); | ||
yield `: ${varName},${common_1.newLine}`; | ||
} | ||
yield `}${common_1.endOfLine}`; | ||
yield `declare var $refs: typeof __VLS_refs${common_1.endOfLine}`; | ||
} | ||
@@ -86,3 +87,3 @@ function* generateSlotsType() { | ||
yield common_1.newLine; | ||
yield ` & __VLS_WithComponent<'${(0, element_1.getCanonicalComponentName)(node.tag)}', typeof __VLS_components, `; | ||
yield ` & __VLS_WithComponent<'${(0, element_1.getCanonicalComponentName)(node.tag)}', typeof __VLS_localComponents, `; | ||
yield (0, element_1.getPossibleOriginalComponentNames)(node.tag, false) | ||
@@ -89,0 +90,0 @@ .map(name => `"${name}"`) |
@@ -22,6 +22,6 @@ "use strict"; | ||
const defineProp = []; | ||
const bindings = parseBindingRanges(ts, ast); | ||
const text = ast.text; | ||
const leadingCommentEndOffset = ts.getLeadingCommentRanges(text, 0)?.reverse()[0].end ?? 0; | ||
const importComponentNames = new Set(); | ||
let bindings = parseBindingRanges(ts, ast); | ||
ts.forEachChild(ast, node => { | ||
@@ -55,2 +55,7 @@ const isTypeExport = (ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node)) && node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); | ||
ts.forEachChild(ast, child => visitNode(child, [ast])); | ||
const templateRefNames = new Set(templateRefs.map(ref => ref.name)); | ||
bindings = bindings.filter(range => { | ||
const name = text.substring(range.start, range.end); | ||
return !templateRefNames.has(name); | ||
}); | ||
return { | ||
@@ -57,0 +62,0 @@ leadingCommentEndOffset, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const shouldAddSuffix = /(?<=<[^>/]+)$/; | ||
const plugin = ({ modules }) => { | ||
@@ -9,9 +10,28 @@ return { | ||
const compiler = modules['@vue/compiler-dom']; | ||
return compiler.compile(template, { | ||
let addedSuffix = false; | ||
// #4583 | ||
if (shouldAddSuffix.test(template)) { | ||
template += '>'; | ||
addedSuffix = true; | ||
} | ||
const result = compiler.compile(template, { | ||
...options, | ||
comments: true, | ||
}); | ||
// @ts-expect-error | ||
result.__addedSuffix = addedSuffix; | ||
return result; | ||
} | ||
}, | ||
updateSFCTemplate(oldResult, change) { | ||
oldResult.code = oldResult.code.slice(0, change.start) | ||
+ change.newText | ||
+ oldResult.code.slice(change.end); | ||
// @ts-expect-error | ||
if (oldResult.__addedSuffix) { | ||
const originalTemplate = oldResult.code.slice(0, -1); // remove added '>' | ||
if (!shouldAddSuffix.test(originalTemplate)) { | ||
return undefined; | ||
} | ||
} | ||
const CompilerDOM = modules['@vue/compiler-dom']; | ||
@@ -111,4 +131,12 @@ const lengthDiff = change.newText.length - (change.end - change.start); | ||
]) { | ||
if (child && !tryUpdateNode(child)) { | ||
return false; | ||
if (child) { | ||
if (!tryUpdateNode(child)) { | ||
return false; | ||
} | ||
if (child.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
const content = child.content.trim(); | ||
if (content.startsWith('(') || content.endsWith(')')) { | ||
return false; | ||
} | ||
} | ||
} | ||
@@ -115,0 +143,0 @@ } |
@@ -104,3 +104,2 @@ import type { Mapping } from '@volar/language-core'; | ||
readonly OmitIndexSignature: string; | ||
readonly PickRefsExpose: string; | ||
}; | ||
@@ -107,0 +106,0 @@ inlayHints: import("../codegen/types").InlayHintInfo[]; |
@@ -48,2 +48,3 @@ import type { CodeInformation } from '@volar/language-core'; | ||
experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>; | ||
__setupedGlobalTypes?: () => boolean; | ||
__test?: boolean; | ||
@@ -50,0 +51,0 @@ } |
{ | ||
"name": "@vue/language-core", | ||
"version": "2.1.2", | ||
"version": "2.1.4", | ||
"license": "MIT", | ||
@@ -39,3 +39,3 @@ "files": [ | ||
}, | ||
"gitHead": "4e4b839ea20ae11a2aef7ee9206465cb60a4be53" | ||
"gitHead": "5e197d08eaef57209ff2927c943ba1db3bf4eff6" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
332874
128
7440