How to use the typescript.createIdentifier function in typescript

To help you get started, we’ve selected a few typescript 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 Bearer / bearer-js / packages / transpiler / src / transformers / output-decorator.ts View on Github external
function createFunctionCall(meta: OutputMeta) {
  const newValueInitializer = ts.createBinary(
    ts.createIdentifier(data),
    ts.createToken(ts.SyntaxKind.BarBarToken),
    ts.createPropertyAccess(ts.createThis(), meta.propDeclarationName)
  )
  // TODO use referenceKeyName
  const emit = createEmitCall(meta, [
    ts.createShorthandPropertyAssignment(meta.referenceKeyName),
    ts.createPropertyAssignment(meta.propDeclarationName, newValueInitializer)
  ])

  return ts.createCall(
    ts.createPropertyAccess(
      ts.createCall(ts.createPropertyAccess(ts.createThis(), meta.functionName), undefined, [
        ts.createObjectLiteral([
          ts.createPropertyAssignment(meta.functionPropertyName, ts.createIdentifier(newValue)),
          ts.createPropertyAssignment(
            meta.functionReferenceIdKeyName,
github ionic-team / ionic-native / scripts / build / transformers / methods.ts View on Github external
function getMethodBlock(method: ts.MethodDeclaration, decoratorName: string, decoratorArgs: any): ts.Expression {
  const decoratorMethod = getMethodsForDecorator(decoratorName)[0];

  switch (decoratorName) {
    case 'CordovaCheck':
    case 'InstanceCheck':
      // TODO remove function wrapper
      return ts.createImmediatelyInvokedArrowFunction([ts.createIf(
        ts.createBinary(
          ts.createCall(ts.createIdentifier(decoratorMethod), undefined, [ts.createThis()]),
          ts.SyntaxKind.EqualsEqualsEqualsToken,
          ts.createTrue()
        ),
        method.body
      )]);

    default:
      return ts.createCall(ts.createIdentifier(decoratorMethod), undefined, [
        ts.createThis(),
        ts.createLiteral((method.name as any).text),
        convertValueToLiteral(decoratorArgs),
        ts.createIdentifier('arguments')
      ]);
  }

}
github HearTao / ts-creator / src / helper.ts View on Github external
function connectBinary(op: BinaryOperator, nodes: Expression[]): Expression {
  if (nodes.length === 0) {
    return createIdentifier('undefined')
  }
  if (nodes.length === 1) {
    return nodes[0]
  }
  return createBinary(nodes[0], op, connectBinary(op, nodes.slice(1)))
}
github takefumi-yoshii / vuex-guardian / src / createShimsAst / strictDispatch.ts View on Github external
ts.createIdentifier('T'),
            ts.createTypeOperatorNode(
              ts.createTypeReferenceNode(
                ts.createIdentifier('A'),
                undefined
              )
            ),
            undefined
          )
        ],
        [
          ts.createParameter(
            undefined,
            undefined,
            undefined,
            ts.createIdentifier('type'),
            undefined,
            ts.createTypeReferenceNode(
              ts.createIdentifier('T'),
              undefined
            ),
            undefined
          ),
          ts.createParameter(
            undefined,
            undefined,
            undefined,
            ts.createIdentifier('payload'),
            ts.createToken(ts.SyntaxKind.QuestionToken),
            ts.createIndexedAccessTypeNode(
              ts.createTypeReferenceNode(
                ts.createIdentifier('A'),
github bs-community / blessing-skin-server / scripts / generateUrls.ts View on Github external
.map(([key, value]) => {
      if (typeof value === 'string') {
        return ts.createPropertyAssignment(
          ts.createIdentifier(key),
          parseURI(value),
        )
      } else {
        return ts.createPropertyAssignment(
          ts.createIdentifier(key),
          parseTree(value),
        )
      }
    })
github woutervh- / typescript-is / src / transform-inline / visitor.ts View on Github external
)
            )
        );
        visitorContext.typeMapperStack.push(mapper);
        for (const property of properties) {
            conditions.push(visitPropertySymbol(property, accessor, visitorContext));
        }
        const stringIndexType = visitorContext.checker.getIndexTypeOfType(type, ts.IndexKind.String);
        if (stringIndexType) {
            const keyIdentifier = ts.createIdentifier('key');
            const itemAccessor = ts.createElementAccess(accessor, keyIdentifier);
            conditions.push(
                ts.createCall(
                    ts.createPropertyAccess(
                        ts.createCall(
                            ts.createPropertyAccess(ts.createIdentifier('Object'), ts.createIdentifier('keys')),
                            undefined,
                            [accessor]
                        ),
                        ts.createIdentifier('every')
                    ),
                    undefined,
                    [
                        ts.createArrowFunction(
                            undefined,
                            undefined,
                            [
                                ts.createParameter(
                                    undefined,
                                    undefined,
                                    undefined,
                                    keyIdentifier
github Bearer / bearer-js / packages / transpiler / src / transformers / input-decorator.ts View on Github external
function createEventListener(meta: InputMeta) {
  const referenceIdIdentifier = ts.createIdentifier('event.detail.referenceId')
  const propAccessIdentifier = ts.createPropertyAccess(ts.createThis(), meta.propertyReferenceIdName)
  return ts.createMethod(
    [
      ts.createDecorator(
        ts.createCall(ts.createIdentifier(Decorators.Listen), undefined, [ts.createLiteral(`body:${meta.eventName}`)])
      )
    ],
    undefined,
    undefined,
    `${meta.propertyReferenceIdName}Changed`,
    undefined,
    undefined,
    [ts.createParameter(undefined, undefined, undefined, ts.createIdentifier('event'), undefined, undefined)],
    undefined,
    ts.createBlock(
      [
github bs-community / blessing-skin-server / scripts / generateUrls.ts View on Github external
ts.createIdentifier(param),
          undefined,
          type,
          undefined,
        ),
      ],
      undefined,
      ts.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
      ts.createTemplateExpression(
        ts.createTemplateHead(
          '/' + uri.slice(0, matches.index),
          '/' + uri.slice(0, matches.index),
        ),
        [
          ts.createTemplateSpan(
            ts.createIdentifier(param),
            ts.createTemplateTail(
              uri.slice(matches.index + matches[0].length),
              uri.slice(matches.index + matches[0].length),
            ),
          ),
        ],
      ),
    )
  }

  return ts.createArrowFunction(
    undefined,
    undefined,
    [],
    undefined,
    ts.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
github woutervh- / typescript-is / src / transform-inline / validation-report-solver.ts View on Github external
function createDisjunctionExpression(validationReport: DisjunctionValidationReport, reportError: boolean): ts.Expression {
    const conditions = validationReport.reports.map((report) => createExpression(report, reportError));
    if (reportError) {
        const errorsIdentifier = ts.createIdentifier('errors');
        const errorIdentifier = ts.createIdentifier('error');
        const prevIdentifier = ts.createIdentifier('prev');
        const nextIdentifier = ts.createIdentifier('next');
        return ts.createArrowFunction(
            undefined,
            undefined,
            [],
            undefined,
            undefined,
            ts.createBlock([
                ts.createVariableStatement(
                    [ts.createModifier(ts.SyntaxKind.ConstKeyword)],
                    [ts.createVariableDeclaration(
                        errorsIdentifier,
                        undefined,
                        ts.createCall(
                            ts.createPropertyAccess(
                                ts.createArrayLiteral(conditions),
github airtasker / spot / lib / src / generators / typescript / axios-client.ts View on Github external
ts.createPropertyAssignment(
                      "params",
                      ts.createObjectLiteral(
                        [...endpoint.queryParams].map(queryParam =>
                          ts.createPropertyAssignment(
                            ts.createStringLiteral(queryParam.name),
                            ts.createIdentifier(queryParam.name)
                          )
                        )
                      )
                    ),
                    ...(includeRequest
                      ? [
                          ts.createPropertyAssignment(
                            "data",
                            ts.createIdentifier(REQUEST_PARAMETER)
                          )
                        ]
                      : []),
                    ts.createPropertyAssignment(
                      "validateStatus",
                      ts.createArrowFunction(
                        /*modifiers*/ undefined,
                        /*typeParameters*/ undefined,
                        [],
                        /*type*/ undefined,
                        /*equalsGreaterThanToken*/ undefined,
                        ts.createLiteral(true)
                      )
                    )
                  ],
                  /*multiLine*/ true