@vue/language-core 3.0.0-alpha.2 → 3.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEv
13
13
  ].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts';
14
14
  }
15
15
  function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) {
16
- const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${checkUnknownProps ? '' : ' & Record<string, unknown>'}`;
16
+ const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${checkUnknownProps ? '' : ' & Record<string, unknown>'}`;
17
17
  let text = ``;
18
18
  if (target < 3.5) {
19
19
  text += `
@@ -51,10 +51,31 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
51
51
  N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
52
52
  N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
53
53
  ${checkUnknownComponents ? '{}' : '{ [K in N0]: unknown }'};
54
- type __VLS_FunctionalComponentProps<T, K> =
55
- '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
56
- : T extends (props: infer P, ...args: any) => any ? P :
57
- {};
54
+ type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
55
+ ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
56
+ , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
57
+ >;
58
+ type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}>
59
+ ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
60
+ : T extends (props: infer P, ...args: any) => any ? P
61
+ : {};
62
+ type __VLS_FunctionalComponent<T> = (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
63
+ __ctx?: {
64
+ attrs?: any,
65
+ slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>,
66
+ emit?: T extends { $emit: infer Emit } ? Emit : {},
67
+ props?: ${fnPropsType},
68
+ expose?: (exposed: T) => void,
69
+ }
70
+ };
71
+ type __VLS_NormalizeSlotReturns<S, R = NonNullable<S> extends (...args: any) => infer K ? K : any> = R extends any[] ? {
72
+ [K in keyof R]: R[K] extends infer V
73
+ ? V extends Element ? V
74
+ : V extends new (...args: any) => infer R ? ReturnType<__VLS_FunctionalComponent<R>>
75
+ : V extends (...args: any) => infer R ? R
76
+ : any
77
+ : never
78
+ } : R;
58
79
  type __VLS_IsFunction<T, K> = K extends keyof T
59
80
  ? __VLS_IsAny<T[K]> extends false
60
81
  ? unknown extends T[K]
@@ -62,13 +83,13 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
62
83
  : true
63
84
  : false
64
85
  : false;
65
- type __VLS_NormalizeComponentEvent<Props, Events, onEvent extends keyof Props, Event extends keyof Events, CamelizedEvent extends keyof Events> = (
86
+ type __VLS_NormalizeComponentEvent<Props, Emits, onEvent extends keyof Props, Event extends keyof Emits, CamelizedEvent extends keyof Emits> = (
66
87
  __VLS_IsFunction<Props, onEvent> extends true
67
88
  ? Props
68
- : __VLS_IsFunction<Events, Event> extends true
69
- ? { [K in onEvent]?: Events[Event] }
70
- : __VLS_IsFunction<Events, CamelizedEvent> extends true
71
- ? { [K in onEvent]?: Events[CamelizedEvent] }
89
+ : __VLS_IsFunction<Emits, Event> extends true
90
+ ? { [K in onEvent]?: Emits[Event] }
91
+ : __VLS_IsFunction<Emits, CamelizedEvent> extends true
92
+ ? { [K in onEvent]?: Emits[CamelizedEvent] }
72
93
  : Props
73
94
  )${checkUnknownEvents ? '' : ' & Record<string, unknown>'};
74
95
  // fix https://github.com/vuejs/language-tools/issues/926
@@ -94,11 +115,16 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
94
115
  }
95
116
  >
96
117
  >;
118
+ type __VLS_ResolveEmits<
119
+ Comp,
120
+ Emits,
121
+ TypeEmits = ${target >= 3.6 ? `Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : import('${lib}').ShortEmitsToObject<T> : {}` : `{}`},
122
+ NormalizedEmits = __VLS_NormalizeEmits<Emits> extends infer E ? string extends keyof E ? {} : E : never,
123
+ > = __VLS_SpreadMerge<NormalizedEmits, TypeEmits>;
124
+ type __VLS_ResolveDirectives<T> = {
125
+ [K in Exclude<keyof T, keyof __VLS_GlobalDirectives> & string as \`v\${Capitalize<K>}\`]: T[K];
126
+ };
97
127
  type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
98
- type __VLS_PickFunctionalComponentCtx<T, K> = NonNullable<__VLS_PickNotAny<
99
- '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
100
- , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
101
- >>;
102
128
  type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;
103
129
 
104
130
  function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
@@ -123,19 +149,13 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
123
149
  : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
124
150
  function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
125
151
  function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
126
- T extends new (...args: any) => any
127
- ? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
128
- __ctx?: {
129
- attrs?: any;
130
- slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : any;
131
- emit?: K extends { $emit: infer Emit } ? Emit : any;
132
- expose?(exposed: K): void;
133
- props?: ${fnPropsType};
134
- }
135
- }
152
+ T extends new (...args: any) => any ? __VLS_FunctionalComponent<K>
136
153
  : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
154
+ ${(target === 2.7
155
+ ? `: T extends import('vue').AsyncComponent ? (props: {}, ctx?: any) => any`
156
+ : ``)}
137
157
  : T extends (...args: any) => any ? T
138
- : (_: {}${checkUnknownProps ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${checkUnknownProps ? '' : ' & Record<string, unknown>'} } };
158
+ : __VLS_FunctionalComponent<{}>;
139
159
  function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
140
160
  function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownComponents ? '' : ' & Record<string, unknown>'}) => void;
141
161
  function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSrc = generateSrc;
4
4
  const codeFeatures_1 = require("../codeFeatures");
5
5
  const utils_1 = require("../utils");
6
+ const wrapWith_1 = require("../utils/wrapWith");
6
7
  function* generateSrc(src) {
7
8
  if (src === true) {
8
9
  return;
@@ -21,10 +22,10 @@ function* generateSrc(src) {
21
22
  text = text + '.js';
22
23
  }
23
24
  yield `export * from `;
24
- yield* (0, utils_1.generateSfcBlockAttrValue)(src, text, {
25
+ yield* (0, wrapWith_1.wrapWith)(src.offset, src.offset + src.text.length, 'main', {
25
26
  ...codeFeatures_1.codeFeatures.all,
26
- ...text === src.text ? codeFeatures_1.codeFeatures.navigation : codeFeatures_1.codeFeatures.navigationWithoutRename,
27
- });
27
+ ...text !== src.text ? codeFeatures_1.codeFeatures.navigationWithoutRename : {},
28
+ }, `'`, [text.slice(0, src.text.length), 'main', src.offset, utils_1.combineLastMapping], text.slice(src.text.length), `'`);
28
29
  yield utils_1.endOfLine;
29
30
  yield `export { default } from '${text}'${utils_1.endOfLine}`;
30
31
  }
@@ -51,7 +51,7 @@ function* generateTemplateElements() {
51
51
  yield `let __VLS_elements!: __VLS_IntrinsicElements${utils_1.endOfLine}`;
52
52
  }
53
53
  function* generateTemplateComponents(options) {
54
- const types = [];
54
+ const types = [`typeof __VLS_ctx`];
55
55
  if (options.sfc.script && options.scriptRanges?.exportDefault?.componentsOption) {
56
56
  const { componentsOption } = options.scriptRanges.exportDefault;
57
57
  yield `const __VLS_componentsOption = `;
@@ -64,7 +64,6 @@ function* generateTemplateComponents(options) {
64
64
  yield utils_1.endOfLine;
65
65
  types.push(`typeof __VLS_componentsOption`);
66
66
  }
67
- types.push(`typeof __VLS_ctx`);
68
67
  yield `type __VLS_LocalComponents =`;
69
68
  for (const type of types) {
70
69
  yield ` & `;
@@ -74,7 +73,7 @@ function* generateTemplateComponents(options) {
74
73
  yield `let __VLS_components!: __VLS_LocalComponents & __VLS_GlobalComponents${utils_1.endOfLine}`;
75
74
  }
76
75
  function* generateTemplateDirectives(options) {
77
- const types = [];
76
+ const types = [`typeof __VLS_ctx`];
78
77
  if (options.sfc.script && options.scriptRanges?.exportDefault?.directivesOption) {
79
78
  const { directivesOption } = options.scriptRanges.exportDefault;
80
79
  yield `const __VLS_directivesOption = `;
@@ -85,9 +84,8 @@ function* generateTemplateDirectives(options) {
85
84
  codeFeatures_1.codeFeatures.navigation,
86
85
  ];
87
86
  yield utils_1.endOfLine;
88
- types.push(`typeof __VLS_directivesOption`);
87
+ types.push(`__VLS_ResolveDirectives<typeof __VLS_directivesOption>`);
89
88
  }
90
- types.push(`typeof __VLS_ctx`);
91
89
  yield `type __VLS_LocalDirectives =`;
92
90
  for (const type of types) {
93
91
  yield ` & `;
@@ -161,6 +161,7 @@ export declare function createTemplateCodegenContext(options: Pick<TemplateCodeg
161
161
  }[]>;
162
162
  currentComponent: {
163
163
  ctxVar: string;
164
+ childTypes: string[];
164
165
  used: boolean;
165
166
  } | undefined;
166
167
  singleRootElTypes: string[];
@@ -35,9 +35,11 @@ function* generateComponent(options, ctx, node) {
35
35
  const componentVNodeVar = ctx.getInternalVariable();
36
36
  const componentCtxVar = ctx.getInternalVariable();
37
37
  const isComponentTag = node.tag.toLowerCase() === 'component';
38
+ ctx.currentComponent?.childTypes.push(`typeof ${componentVNodeVar}`);
38
39
  ctx.currentComponent = {
39
40
  ctxVar: componentCtxVar,
40
- used: false
41
+ childTypes: [],
42
+ used: false,
41
43
  };
42
44
  let props = node.props;
43
45
  let dynamicTagInfo;
@@ -159,7 +161,7 @@ function* generateComponent(options, ctx, node) {
159
161
  yield* (0, wrapWith_1.wrapWith)(tagOffsets[0], tagOffsets[0] + node.tag.length, ctx.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, true, failedPropExps), `}`);
160
162
  yield `, ...__VLS_functionalComponentArgsRest(${componentFunctionalVar}))${utils_1.endOfLine}`;
161
163
  yield* generateFailedPropExps(options, ctx, failedPropExps);
162
- yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentFunctionalVar, componentVNodeVar, componentCtxVar);
164
+ yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentOriginalVar, componentFunctionalVar, componentVNodeVar, componentCtxVar);
163
165
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
164
166
  const [refName, offset] = yield* generateElementReference(options, ctx, node);
165
167
  const tag = (0, shared_2.hyphenateTag)(node.tag);
@@ -188,7 +190,7 @@ function* generateComponent(options, ctx, node) {
188
190
  const slotDir = node.props.find(p => p.type === CompilerDOM.NodeTypes.DIRECTIVE && p.name === 'slot');
189
191
  yield* (0, vSlot_1.generateVSlot)(options, ctx, node, slotDir);
190
192
  if (ctx.currentComponent.used) {
191
- yield `var ${componentCtxVar}!: __VLS_PickFunctionalComponentCtx<typeof ${componentOriginalVar}, typeof ${componentVNodeVar}>${utils_1.endOfLine}`;
193
+ yield `var ${componentCtxVar}!: __VLS_FunctionalComponentCtx<typeof ${componentOriginalVar}, typeof ${componentVNodeVar}>${utils_1.endOfLine}`;
192
194
  }
193
195
  }
194
196
  function* generateElement(options, ctx, node) {
@@ -197,6 +199,7 @@ function* generateElement(options, ctx, node) {
197
199
  ? node.loc.start.offset + node.loc.source.lastIndexOf(node.tag)
198
200
  : undefined;
199
201
  const failedPropExps = [];
202
+ ctx.currentComponent?.childTypes.push(`__VLS_NativeElements['${node.tag}']`);
200
203
  yield `__VLS_asFunctionalElement(__VLS_elements`;
201
204
  yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset, ctx.codeFeatures.withoutHighlightAndCompletion);
202
205
  if (endTagOffset !== undefined) {
@@ -223,7 +226,10 @@ function* generateElement(options, ctx, node) {
223
226
  ctx.inheritedAttrVars.add(`__VLS_elements.${node.tag}`);
224
227
  }
225
228
  (0, styleScopedClasses_1.collectStyleScopedClassReferences)(options, ctx, node);
229
+ const { currentComponent } = ctx;
230
+ ctx.currentComponent = undefined;
226
231
  yield* (0, elementChildren_1.generateElementChildren)(options, ctx, node.children);
232
+ ctx.currentComponent = currentComponent;
227
233
  }
228
234
  function* generateFailedPropExps(options, ctx, failedPropExps) {
229
235
  for (const failedExp of failedPropExps) {
@@ -3,7 +3,7 @@ import type * as ts from 'typescript';
3
3
  import type { Code } from '../../types';
4
4
  import type { TemplateCodegenContext } from './context';
5
5
  import type { TemplateCodegenOptions } from './index';
6
- export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>;
6
+ export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentOriginalVar: string, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>;
7
7
  export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string): Generator<Code>;
8
8
  export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
9
9
  export declare function generateModelEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
@@ -11,9 +11,9 @@ const utils_1 = require("../utils");
11
11
  const camelized_1 = require("../utils/camelized");
12
12
  const wrapWith_1 = require("../utils/wrapWith");
13
13
  const interpolation_1 = require("./interpolation");
14
- function* generateElementEvents(options, ctx, node, componentFunctionalVar, componentVNodeVar, componentCtxVar) {
15
- let emitVar;
16
- let eventsVar;
14
+ const objectProperty_1 = require("./objectProperty");
15
+ function* generateElementEvents(options, ctx, node, componentOriginalVar, componentFunctionalVar, componentVNodeVar, componentCtxVar) {
16
+ let emitsVar;
17
17
  let propsVar;
18
18
  for (const prop of node.props) {
19
19
  if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE
@@ -23,12 +23,10 @@ function* generateElementEvents(options, ctx, node, componentFunctionalVar, comp
23
23
  && prop.name === 'model'
24
24
  && (!prop.arg || prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic))) {
25
25
  ctx.currentComponent.used = true;
26
- if (!emitVar) {
27
- emitVar = ctx.getInternalVariable();
28
- eventsVar = ctx.getInternalVariable();
26
+ if (!emitsVar) {
27
+ emitsVar = ctx.getInternalVariable();
29
28
  propsVar = ctx.getInternalVariable();
30
- yield `let ${emitVar}!: typeof ${componentCtxVar}.emit${utils_1.endOfLine}`;
31
- yield `let ${eventsVar}!: __VLS_NormalizeEmits<typeof ${emitVar}>${utils_1.endOfLine}`;
29
+ yield `let ${emitsVar}!: __VLS_ResolveEmits<typeof ${componentOriginalVar}, typeof ${componentCtxVar}.emit>${utils_1.endOfLine}`;
32
30
  yield `let ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentFunctionalVar}, typeof ${componentVNodeVar}>${utils_1.endOfLine}`;
33
31
  }
34
32
  let source = prop.arg?.loc.source ?? 'model-value';
@@ -45,7 +43,13 @@ function* generateElementEvents(options, ctx, node, componentFunctionalVar, comp
45
43
  propPrefix = 'onVnode-';
46
44
  emitPrefix = 'vnode-';
47
45
  }
48
- yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${eventsVar}, '${(0, shared_1.camelize)(propPrefix + source)}', '${emitPrefix + source}', '${(0, shared_1.camelize)(emitPrefix + source)}'> => ({${utils_1.newLine}`;
46
+ yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${(0, shared_1.camelize)(propPrefix + source)}', '${emitPrefix + source}', '${(0, shared_1.camelize)(emitPrefix + source)}'> => (${utils_1.newLine}`;
47
+ if (prop.name === 'on') {
48
+ yield `{ `;
49
+ yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, emitPrefix + source, start, ctx.codeFeatures.navigation, undefined, true);
50
+ yield `: {} as any } as typeof ${emitsVar},${utils_1.newLine}`;
51
+ }
52
+ yield `{ `;
49
53
  if (prop.name === 'on') {
50
54
  yield* generateEventArg(ctx, source, start, propPrefix.slice(0, -1));
51
55
  yield `: `;
@@ -28,7 +28,9 @@ function* generateVSlot(options, ctx, node, slotDir) {
28
28
  }
29
29
  }
30
30
  else {
31
- yield* (0, wrapWith_1.wrapWith)(node.children[0].loc.start.offset, node.children.at(-1).loc.end.offset, ctx.codeFeatures.navigation, `default`);
31
+ // #932: reference for implicit default slot
32
+ const { start, end } = getElementInnerLoc(options, node);
33
+ yield* (0, wrapWith_1.wrapWith)(start, end, ctx.codeFeatures.navigation, `default`);
32
34
  }
33
35
  yield `: ${slotVar} } = ${ctx.currentComponent.ctxVar}.slots!${utils_1.endOfLine}`;
34
36
  }
@@ -44,6 +46,12 @@ function* generateVSlot(options, ctx, node, slotDir) {
44
46
  for (const varName of slotBlockVars) {
45
47
  ctx.removeLocalVariable(varName);
46
48
  }
49
+ if (options.vueCompilerOptions.strictSlotChildren && node.children.length) {
50
+ const { start, end } = getElementInnerLoc(options, node);
51
+ yield `(): __VLS_NormalizeSlotReturns<typeof ${slotVar}> => (`;
52
+ yield* (0, wrapWith_1.wrapWith)(start, end, ctx.codeFeatures.verification, `{} as [`, ...ctx.currentComponent.childTypes.map(name => `${name}, `), `]`);
53
+ yield `)${utils_1.endOfLine}`;
54
+ }
47
55
  if (slotDir) {
48
56
  let isStatic = true;
49
57
  if (slotDir.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
@@ -112,4 +120,26 @@ function* generateSlotParameters(options, ctx, ast, exp, slotVar) {
112
120
  ];
113
121
  }
114
122
  }
123
+ function getElementInnerLoc(options, node) {
124
+ if (node.children.length) {
125
+ let start = node.children[0].loc.start.offset;
126
+ let end = node.children.at(-1).loc.end.offset;
127
+ while (options.template.content[start - 1] !== '>') {
128
+ start--;
129
+ }
130
+ while (options.template.content[end] !== '<') {
131
+ end++;
132
+ }
133
+ return {
134
+ start,
135
+ end,
136
+ };
137
+ }
138
+ else {
139
+ return {
140
+ start: node.loc.start.offset,
141
+ end: node.loc.end.offset,
142
+ };
143
+ }
144
+ }
115
145
  //# sourceMappingURL=vSlot.js.map
@@ -1,6 +1,6 @@
1
1
  import * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type * as ts from 'typescript';
3
- import type { Code, SfcBlock, SfcBlockAttr, VueCodeInformation } from '../../types';
3
+ import type { Code, SfcBlock, VueCodeInformation } from '../../types';
4
4
  export declare const newLine = "\n";
5
5
  export declare const endOfLine = ";\n";
6
6
  export declare const combineLastMapping: VueCodeInformation;
@@ -18,4 +18,3 @@ export declare function collectIdentifiers(ts: typeof import('typescript'), node
18
18
  export declare function normalizeAttributeValue(node: CompilerDOM.TextNode): [string, number];
19
19
  export declare function createTsAst(ts: typeof import('typescript'), astHolder: any, text: string): ts.SourceFile;
20
20
  export declare function generateSfcBlockSection(block: SfcBlock, start: number, end: number, features: VueCodeInformation): Code;
21
- export declare function generateSfcBlockAttrValue(src: SfcBlockAttr & object, text: string, features: VueCodeInformation): Generator<Code>;
@@ -6,7 +6,6 @@ exports.collectIdentifiers = collectIdentifiers;
6
6
  exports.normalizeAttributeValue = normalizeAttributeValue;
7
7
  exports.createTsAst = createTsAst;
8
8
  exports.generateSfcBlockSection = generateSfcBlockSection;
9
- exports.generateSfcBlockAttrValue = generateSfcBlockAttrValue;
10
9
  const shared_1 = require("../../utils/shared");
11
10
  exports.newLine = `\n`;
12
11
  exports.endOfLine = `;${exports.newLine}`;
@@ -65,19 +64,4 @@ function generateSfcBlockSection(block, start, end, features) {
65
64
  features,
66
65
  ];
67
66
  }
68
- function* generateSfcBlockAttrValue(src, text, features) {
69
- const { offset, quotes } = src;
70
- if (!quotes) {
71
- yield [``, 'main', offset, { verification: true }];
72
- }
73
- yield [
74
- `'${text}'`,
75
- 'main',
76
- quotes ? offset - 1 : offset,
77
- features
78
- ];
79
- if (!quotes) {
80
- yield [``, 'main', offset + text.length, { __combineOffset: 2 }];
81
- }
82
- }
83
67
  //# sourceMappingURL=index.js.map
@@ -21,7 +21,7 @@ const plugin = () => {
21
21
  if (embeddedFile.id !== 'template_inline_css' || !sfc.template?.ast) {
22
22
  return;
23
23
  }
24
- embeddedFile.parentCodeId = 'template';
24
+ embeddedFile.parentCodeId = sfc.template.lang === 'md' ? 'root_tags' : 'template';
25
25
  embeddedFile.content.push(...generate(sfc.template.ast));
26
26
  },
27
27
  };
@@ -38,13 +38,13 @@ const plugin = ctx => {
38
38
  },
39
39
  resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
40
40
  // access template content to watch change
41
- (() => sfc.template?.content)();
41
+ void sfc.template?.content;
42
42
  const parsed = parseds.get(sfc);
43
43
  if (parsed) {
44
44
  const codes = parsed.get(embeddedFile.id);
45
45
  if (codes) {
46
46
  embeddedFile.content.push(...codes);
47
- embeddedFile.parentCodeId = 'template';
47
+ embeddedFile.parentCodeId = sfc.template?.lang === 'md' ? 'root_tags' : 'template';
48
48
  }
49
49
  }
50
50
  },
@@ -198,6 +198,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
198
198
  }[]>;
199
199
  currentComponent: {
200
200
  ctxVar: string;
201
+ childTypes: string[];
201
202
  used: boolean;
202
203
  } | undefined;
203
204
  singleRootElTypes: string[];
package/lib/types.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface VueCompilerOptions {
23
23
  vitePressExtensions: string[];
24
24
  petiteVueExtensions: string[];
25
25
  jsxSlots: boolean;
26
+ strictSlotChildren: boolean;
26
27
  strictVModel: boolean;
27
28
  checkUnknownProps: boolean;
28
29
  checkUnknownEvents: boolean;
package/lib/utils/ts.js CHANGED
@@ -217,6 +217,7 @@ function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = f
217
217
  vitePressExtensions: [],
218
218
  petiteVueExtensions: [],
219
219
  jsxSlots: false,
220
+ strictSlotChildren: strictTemplates,
220
221
  strictVModel: strictTemplates,
221
222
  checkUnknownProps: strictTemplates,
222
223
  checkUnknownEvents: strictTemplates,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -37,5 +37,5 @@
37
37
  "optional": true
38
38
  }
39
39
  },
40
- "gitHead": "79247b7c24b7202ec676723440fdb36c38e6d450"
40
+ "gitHead": "1769cd6b94ec9e0cc2681b8dbba904f35856ba1c"
41
41
  }
@@ -1,3 +0,0 @@
1
- import type { Code, VueCodeInformation } from '../../types';
2
- export declare function getObjectProperty(code: string): string;
3
- export declare function generateObjectProperty(code: string, source: string, offset: number, features: VueCodeInformation, hasQuotes?: boolean, shouldCamelize?: boolean): Generator<Code>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getObjectProperty = getObjectProperty;
4
- exports.generateObjectProperty = generateObjectProperty;
5
- const shared_1 = require("@vue/shared");
6
- const utils_1 = require("../utils");
7
- const camelized_1 = require("../utils/camelized");
8
- const stringLiteralKey_1 = require("../utils/stringLiteralKey");
9
- function getObjectProperty(code) {
10
- if (utils_1.identifierRegex.test(code)) {
11
- return code;
12
- }
13
- else {
14
- return `'${code}'`;
15
- }
16
- }
17
- function* generateObjectProperty(code, source, offset, features, hasQuotes = false, shouldCamelize = false) {
18
- const start = offset;
19
- const end = offset + code.length;
20
- if (hasQuotes) {
21
- code = code.slice(1, -1);
22
- offset++;
23
- }
24
- if (shouldCamelize) {
25
- if (utils_1.identifierRegex.test((0, shared_1.camelize)(code))) {
26
- yield* (0, camelized_1.generateCamelized)(code, source, offset, features);
27
- }
28
- else {
29
- yield* (0, utils_1.wrapWith)(start, end, source, features, `'`, ...(0, camelized_1.generateCamelized)(code, source, offset, features), `'`);
30
- }
31
- }
32
- else {
33
- if (utils_1.identifierRegex.test(code)) {
34
- yield [code, source, offset, features];
35
- }
36
- else {
37
- yield* (0, stringLiteralKey_1.generateStringLiteralKey)(code, source, offset, features);
38
- }
39
- }
40
- }
41
- //# sourceMappingURL=objectProperty.js.map