Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: string,
closureType: string|null|undefined,
templateTypes: string[] = [],
): ts.ParamType {
if (!closureType) {
return new ts.ParamType({
name,
type: ts.anyType,
optional: false,
rest: false,
});
}
let ast;
try {
ast = parseParamType(closureType);
} catch {
return new ts.ParamType({
name,
type: ts.anyType,
// It's important we try to get optional right even if we can't parse
// the annotation, because non-optional arguments can't follow optional
// ones.
optional: closureType.endsWith('='),
rest: false,
});
}
return convertParam(name, ast, templateTypes);
}