Typing
This commit is contained in:
parent
cd44cefa3f
commit
bc015eba1a
|
@ -249,6 +249,18 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isMustacheStatement(
|
||||||
|
node: hbs.AST.Statement
|
||||||
|
): node is hbs.AST.MustacheStatement {
|
||||||
|
return node.type === "MustacheStatement"
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBlockStatement(
|
||||||
|
node: hbs.AST.Statement
|
||||||
|
): node is hbs.AST.BlockStatement {
|
||||||
|
return node.type === "BlockStatement"
|
||||||
|
}
|
||||||
|
|
||||||
async function validateHbsTemplate(
|
async function validateHbsTemplate(
|
||||||
editor: EditorView,
|
editor: EditorView,
|
||||||
template: string,
|
template: string,
|
||||||
|
@ -259,13 +271,13 @@
|
||||||
try {
|
try {
|
||||||
const ast = Handlebars.parse(template)
|
const ast = Handlebars.parse(template)
|
||||||
|
|
||||||
function traverseNodes(nodes: any[]) {
|
function traverseNodes(nodes: hbs.AST.Statement[]) {
|
||||||
nodes.forEach(node => {
|
nodes.forEach(node => {
|
||||||
if (
|
if (
|
||||||
node.type === "MustacheStatement" &&
|
isMustacheStatement(node) &&
|
||||||
node.path.type === "PathExpression"
|
node.path.type === "PathExpression"
|
||||||
) {
|
) {
|
||||||
const helperName = node.path.original
|
const helperName = (node.path as hbs.AST.PathExpression).original
|
||||||
|
|
||||||
const from =
|
const from =
|
||||||
editor.state.doc.line(node.loc.start.line).from +
|
editor.state.doc.line(node.loc.start.line).from +
|
||||||
|
@ -303,7 +315,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.program) {
|
if (isBlockStatement(node)) {
|
||||||
traverseNodes(node.program.body)
|
traverseNodes(node.program.body)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -332,7 +344,6 @@
|
||||||
complete.push(
|
complete.push(
|
||||||
autocompletion({
|
autocompletion({
|
||||||
override: [...completions],
|
override: [...completions],
|
||||||
// override: [...completions.map(c => c.completionDelegate)],
|
|
||||||
closeOnBlur: true,
|
closeOnBlur: true,
|
||||||
icons: false,
|
icons: false,
|
||||||
optionClass: completion =>
|
optionClass: completion =>
|
||||||
|
|
Loading…
Reference in New Issue