mirror of https://github.com/sveltejs/svelte
pull/8569/head
parent
64e1509d27
commit
99a108d920
@ -1,17 +1,21 @@
|
|||||||
import ConstTag from '../../../nodes/ConstTag';
|
/** @param {ConstTag[]} const_tags */
|
||||||
|
export function get_const_tags(const_tags) {
|
||||||
export function get_const_tags(const_tags: ConstTag[]) {
|
if (const_tags.length === 0)
|
||||||
if (const_tags.length === 0) return null;
|
return null;
|
||||||
return {
|
return {
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
kind: 'let',
|
kind: 'let',
|
||||||
declarations: const_tags.map((const_tag) => {
|
declarations: const_tags.map((const_tag) => {
|
||||||
const assignment = const_tag.node.expression;
|
const assignment = const_tag.node.expression;
|
||||||
return {
|
return {
|
||||||
type: 'VariableDeclarator',
|
type: 'VariableDeclarator',
|
||||||
id: assignment.left,
|
id: assignment.left,
|
||||||
init: assignment.right
|
init: assignment.right
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue