TypeScript @angular-compiler-src-output-output_ast.importType类(方法)实例源码

下面列出了TypeScript @angular-compiler-src-output-output_ast.importType 类(方法)源码代码实例,从而了解它的用法。

作者:ox    项目:angula   
it('should support external types', () => {
   const writeVarExpr = o.variable('a').set(o.NULL_EXPR);
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(sameModuleIdentifier))))
       .toEqual('var a = null;');
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(externalModuleIdentifier))))
       .toEqual(`var a = null;`);
 });

作者:davewrag    项目:angula   
it('should support external types', () => {
   var writeVarExpr = o.variable('a').set(o.NULL_EXPR);
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(sameModuleIdentifier))))
       .toEqual('someLocalId a = null;');
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(externalModuleIdentifier))))
       .toEqual([`import 'someOtherPath' as import0;`, `import0.someExternalId a = null;`].join(
           '\n'));
 });

作者:DanielKuca    项目:angula   
it('should support external types', () => {
   const writeVarExpr = o.variable('a').set(o.NULL_EXPR);
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(sameModuleIdentifier))))
       .toEqual('var a:someLocalId = (null as any);');
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(externalModuleIdentifier)))).toEqual([
     `import * as i0 from 'somePackage/someOtherPath';`,
     `var a:i0.someExternalId = (null as any);`
   ].join('\n'));
 });

作者:manekinekk    项目:angula   
it('should support `importAs` for external types', () => {
   spyOn(importResolver, 'getImportAs')
       .and.returnValue(new StaticSymbol('somePackage/importAsModule', 'importAsName', []));
   const writeVarExpr = o.variable('a').set(o.NULL_EXPR);
   expect(emitStmt(writeVarExpr.toDeclStmt(o.importType(externalModuleIdentifier)))).toEqual([
     `import * as import0 from 'somePackage/importAsModule';`,
     `var a:import0.importAsName = (null as any);`
   ].join('\n'));
 });


问题


面经


文章

微信
公众号

扫码关注公众号