How to use the doctrine/lib/typed.js.parseParamType function in doctrine

To help you get started, we’ve selected a few doctrine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Polymer / tools / packages / gen-typescript-declarations / src / closure-types.ts View on Github external
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);
}