Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
type: IRAttributeType.Boolean,
value: true,
};
} else {
return {
name,
location,
type: IRAttributeType.String,
value,
};
}
} catch (error) {
// Removes the attribute, if impossible to parse it value.
removeAttribute(el, name);
addDiagnostic(
normalizeToDiagnostic(ParserDiagnostics.GENERIC_PARSING_ERROR, error, {
location: normalizeLocation(location),
})
);
}
}
let code = '';
const warnings: CompilerDiagnostic[] = [];
try {
const parsingResults = parseTemplate(source, state);
warnings.push(...parsingResults.warnings);
const hasParsingError = parsingResults.warnings.some(
warning => warning.level === DiagnosticLevel.Error
);
if (!hasParsingError && parsingResults.root) {
const output = generate(parsingResults.root, state);
code = output.code;
}
} catch (error) {
const diagnostic = normalizeToDiagnostic(ParserDiagnostics.GENERIC_PARSING_ERROR, error);
diagnostic.message = `Unexpected compilation error: ${diagnostic.message}`;
warnings.push(diagnostic);
}
return {
code,
warnings,
};
}
export function compileToFunction(source: string): Function {