fix(ivy): directives without selector should not be supported (#28021)

PR Close #28021
This commit is contained in:
Marc Laval
2019-01-09 17:55:23 +01:00
committed by Andrew Kushnir
parent 7374dfd1fa
commit 76ed13bffe
4 changed files with 55 additions and 32 deletions

View File

@ -164,9 +164,9 @@ export function compileDirectiveFromMetadata(
addFeatures(definitionMap, meta);
const expression = o.importExpr(R3.defineDirective).callFn([definitionMap.toLiteralMap()]);
// On the type side, remove newlines from the selector as it will need to fit into a TypeScript
// string literal, which must be on one line.
const selectorForType = (meta.selector || '').replace(/\n/g, '');
if (!meta.selector) {
throw new Error(`Directive ${meta.name} has no selector, please add it!`);
}
const type = createTypeForDef(meta, R3.DirectiveDefWithMeta);
return {expression, type, statements};