当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TypeScriptEmitter.emitStatements方法代码示例

本文整理汇总了TypeScript中@angular/compiler/src/output/ts_emitter.TypeScriptEmitter.emitStatements方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TypeScriptEmitter.emitStatements方法的具体用法?TypeScript TypeScriptEmitter.emitStatements怎么用?TypeScript TypeScriptEmitter.emitStatements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/compiler/src/output/ts_emitter.TypeScriptEmitter的用法示例。


在下文中一共展示了TypeScriptEmitter.emitStatements方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: emitStmt

 function emitStmt(stmt: o.Statement | o.Statement[], exportedVars: string[] = null): string {
   if (!exportedVars) {
     exportedVars = [];
   }
   const stmts = Array.isArray(stmt) ? stmt : [stmt];
   return emitter.emitStatements(someModuleUrl, stmts, exportedVars);
 }
开发者ID:doxiaodong,项目名称:angular,代码行数:7,代码来源:ts_emitter_spec.ts

示例2: emit

export function emit() {
  const emitter = new TypeScriptEmitter(new SimpleJsImportGenerator());
  const emittedCode = emitter.emitStatements(
      assetUrl('compiler', 'output/output_emitter_codegen_typed', 'test'), codegenStmts,
      codegenExportsVars);
  return emittedCode;
}
开发者ID:ScottSWu,项目名称:angular,代码行数:7,代码来源:output_emitter_codegen_typed.ts

示例3: emitSourceMap

 function emitSourceMap(
     stmt: o.Statement | o.Statement[], exportedVars: string[] | null = null,
     preamble?: string): SourceMap {
   const stmts = Array.isArray(stmt) ? stmt : [stmt];
   const source = emitter.emitStatements(
       someSourceFilePath, someGenFilePath, stmts, exportedVars || [], preamble);
   return extractSourceMap(source) !;
 }
开发者ID:diestrin,项目名称:angular,代码行数:8,代码来源:ts_emitter_node_only_spec.ts

示例4: emitStmt

 function emitStmt(
     stmt: o.Statement | o.Statement[], exportedVars: string[] = null,
     preamble?: string): string {
   const stmts = Array.isArray(stmt) ? stmt : [stmt];
   const source = emitter.emitStatements(
       someSourceFilePath, someGenFilePath, stmts, exportedVars || [], preamble);
   return stripSourceMapAndNewLine(source);
 }
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:8,代码来源:ts_emitter_spec.ts

示例5: it

  it('should quote identifiers quoted in the source', () => {
    const sourceText = `
      import {Component} from '@angular/core';

      @Component({
        providers: [{ provide: 'SomeToken', useValue: {a: 1, 'b': 2, c: 3, 'd': 4}}]
      })
      export class MyComponent {}
    `;
    const source = ts.createSourceFile('test.ts', sourceText, ts.ScriptTarget.Latest);
    const collector = new MetadataCollector({quotedNames: true});
    const stubHost = new StubReflectorHost();
    const symbolCache = new StaticSymbolCache();
    const symbolResolver =
        new StaticSymbolResolver(stubHost, symbolCache, new MockSummaryResolver());
    const reflector = new StaticReflector(symbolResolver);

    // Get the metadata from the above source
    const metadata = collector.getMetadata(source);
    const componentMetadata = metadata.metadata['MyComponent'];

    // Get the first argument of the decorator call which is passed to @Component
    expect(isClassMetadata(componentMetadata)).toBeTruthy();
    if (!isClassMetadata(componentMetadata)) return;
    const decorators = componentMetadata.decorators;
    const firstDecorator = decorators[0];
    expect(isMetadataSymbolicCallExpression(firstDecorator)).toBeTruthy();
    if (!isMetadataSymbolicCallExpression(firstDecorator)) return;
    const firstArgument = firstDecorator.arguments[0];

    // Simplify this value using the StaticReflector
    const context = reflector.getStaticSymbol('none', 'none');
    const argumentValue = reflector.simplify(context, firstArgument);

    // Convert the value to an output AST
    const outputAst = convertValueToOutputAst(argumentValue);
    const statement = outputAst.toStmt();

    // Convert the value to text using the typescript emitter
    const emitter = new TypeScriptEmitter(new StubImportResolver());
    const text = emitter.emitStatements('module', [statement], []);

    // Expect the keys for 'b' and 'd' to be quoted but 'a' and 'c' not to be.
    expect(text).toContain('\'b\': 2');
    expect(text).toContain('\'d\': 4');
    expect(text).not.toContain('\'a\'');
    expect(text).not.toContain('\'c\'');
  });
开发者ID:DzmitryShylovich,项目名称:angular,代码行数:48,代码来源:ts_emitter_node_only_spec.ts

示例6: emitStmt

 function emitStmt(stmt: o.Statement, exportedVars: string[] = null): string {
   if (isBlank(exportedVars)) {
     exportedVars = [];
   }
   return emitter.emitStatements(someModuleUrl, [stmt], exportedVars);
 }
开发者ID:WimpyKnight,项目名称:angular,代码行数:6,代码来源:ts_emitter_spec.ts

示例7: emitSourceMap

 function emitSourceMap(
     stmt: o.Statement | o.Statement[], exportedVars: string[] = null): SourceMap {
   const stmts = Array.isArray(stmt) ? stmt : [stmt];
   const source = emitter.emitStatements(someModuleUrl, stmts, exportedVars || []);
   return extractSourceMap(source);
 }
开发者ID:manekinekko,项目名称:angular,代码行数:6,代码来源:ts_emitter_node_only_spec.ts

示例8: emitStmt

 function emitStmt(stmt: o.Statement | o.Statement[], exportedVars: string[] = null): string {
   const stmts = Array.isArray(stmt) ? stmt : [stmt];
   const source = emitter.emitStatements(someModuleUrl, stmts, exportedVars || []);
   return stripSourceMapAndNewLine(source);
 }
开发者ID:acramatte,项目名称:angular,代码行数:5,代码来源:ts_emitter_spec.ts


注:本文中的@angular/compiler/src/output/ts_emitter.TypeScriptEmitter.emitStatements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。