Skip to content

Commit

Permalink
refactor(language-core): use non-null assertion instead of `__VLS_non…
Browse files Browse the repository at this point in the history
…Nullable`
  • Loading branch information
KazariEX committed Dec 22, 2024
1 parent 886309e commit b82461d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/language-core/lib/codegen/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
: __VLS_unknownDirective;
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
? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
Expand Down
4 changes: 2 additions & 2 deletions packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function* generateComponentSlot(
`__VLS_thisSlot`
);
}
yield `} = __VLS_nonNullable(${componentCtxVar}.slots)${endOfLine}`;
yield `} = ${componentCtxVar}.slots!${endOfLine}`;

if (slotDir?.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
const slotAst = createTsAst(options.ts, slotDir, `(${slotDir.exp.content}) => {}`);
Expand Down Expand Up @@ -559,7 +559,7 @@ function* generateComponentSlot(
isStatic = slotDir.arg.isStatic;
}
if (isStatic && slotDir && !slotDir.arg) {
yield `__VLS_nonNullable(${componentCtxVar}.slots)['`;
yield `${componentCtxVar}.slots!['`;
yield [
'',
'template',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function* generateElementChildren(
&& node.tagType !== CompilerDOM.ElementTypes.TEMPLATE
) {
ctx.usedComponentCtxVars.add(componentCtxVar);
yield `__VLS_nonNullable(${componentCtxVar}.slots).`;
yield `${componentCtxVar}.slots!.`;
yield* wrapWith(
node.children[0].loc.start.offset,
node.children[node.children.length - 1].loc.end.offset,
Expand Down

0 comments on commit b82461d

Please sign in to comment.