-
Notifications
You must be signed in to change notification settings - Fork 234
/
ngQuery.ts
27 lines (21 loc) · 1.32 KB
/
ngQuery.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as ts from 'typescript';
import { decoratorArgument, getInitializer, getStringInitializerFromProperty, isProperty, WithStringInitializer } from './astQuery';
import { Maybe } from './function';
export function getAnimations(dec: ts.Decorator): Maybe<ts.ArrayLiteralExpression | undefined> {
return decoratorArgument(dec).bind(expr => {
const property = expr!.properties.find(p => isProperty('animations', p))!;
return getInitializer(property).fmap(expr => (ts.isArrayLiteralExpression(expr!) ? (expr as ts.ArrayLiteralExpression) : undefined));
});
}
export function getInlineStyle(dec: ts.Decorator): Maybe<ts.ArrayLiteralExpression | undefined> {
return decoratorArgument(dec).bind(expr => {
const property = expr!.properties.find(p => isProperty('styles', p))!;
return getInitializer(property).fmap(expr => (ts.isArrayLiteralExpression(expr!) ? (expr as ts.ArrayLiteralExpression) : undefined));
});
}
export function getTemplate(dec: ts.Decorator): Maybe<WithStringInitializer | undefined> {
return decoratorArgument(dec).bind(expr => getStringInitializerFromProperty('template', expr!.properties));
}
export function getTemplateUrl(dec: ts.Decorator): Maybe<WithStringInitializer | undefined> {
return decoratorArgument(dec).bind(expr => getStringInitializerFromProperty('templateUrl', expr!.properties));
}