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


TypeScript StaticReflector.annotations方法代码示例

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


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

示例1: it

    it('should inherit annotations', () => {
      initWithDecorator({
        '/tmp/src/main.ts': `
            import {ClassDecorator} from './decorator';

            @ClassDecorator('parent')
            export class Parent {}

            @ClassDecorator('child')
            export class Child extends Parent {}

            export class ChildNoDecorators extends Parent {}

            export class ChildInvalidParent extends a.InvalidParent {}
          `
      });

      // Check that metadata for Parent was not changed!
      expect(reflector.annotations(reflector.getStaticSymbol('/tmp/src/main.ts', 'Parent')))
          .toEqual([new ClassDecorator('parent')]);

      expect(reflector.annotations(reflector.getStaticSymbol('/tmp/src/main.ts', 'Child')))
          .toEqual([new ClassDecorator('parent'), new ClassDecorator('child')]);

      expect(
          reflector.annotations(reflector.getStaticSymbol('/tmp/src/main.ts', 'ChildNoDecorators')))
          .toEqual([new ClassDecorator('parent')]);

      expect(reflector.annotations(
                 reflector.getStaticSymbol('/tmp/src/main.ts', 'ChildInvalidParent')))
          .toEqual([]);
    });
开发者ID:JSMike,项目名称:angular,代码行数:32,代码来源:static_reflector_spec.ts

示例2: it

  it('should continue to aggresively evaluate enum member accessors', () => {
    const data = Object.create(DEFAULT_TEST_DATA);
    const file = '/tmp/src/my_component.ts';
    data[file] = `
      import {Component} from '@angular/core';
      import {intermediate} from './index';

      @Component({
        template: '<div></div>',
        providers: [{provide: 'foo', useValue: [...intermediate]}]
      })
      export class MyComponent { }
    `;
    data['/tmp/src/intermediate.ts'] = `
      import {MyEnum} from './indirect';
      export const intermediate = [{
        data: {
          c: [MyEnum.Value]
        }
      }];`;
    data['/tmp/src/index.ts'] = `export * from './intermediate';`;
    data['/tmp/src/indirect.ts'] = `export * from './consts';`;
    data['/tmp/src/consts.ts'] = `
      export enum MyEnum {
        Value = 3
      }
    `;
    init(data);

    expect(reflector.annotations(reflector.getStaticSymbol(file, 'MyComponent'))[0]
               .providers[0]
               .useValue)
        .toEqual([{data: {c: [3]}}]);
  });
开发者ID:smart-web-rock,项目名称:angular,代码行数:34,代码来源:static_reflector_spec.ts

示例3: expect

 () => {
   const annotations = reflector.annotations(
       reflector.getStaticSymbol('/tmp/src/static-method-call.ts', 'MyCondComponent'));
   expect(annotations.length).toBe(1);
   expect(annotations[0].providers).toEqual([
     [{provider: 'a', useValue: '1'}], [{provider: 'a', useValue: '2'}]
   ]);
 });
开发者ID:JSMike,项目名称:angular,代码行数:8,代码来源:static_reflector_spec.ts

示例4: it

 it('should get annotations for HeroDetailComponent', () => {
   const HeroDetailComponent =
       reflector.findDeclaration('src/app/hero-detail.component', 'HeroDetailComponent');
   const annotations = reflector.annotations(HeroDetailComponent);
   expect(annotations.length).toEqual(1);
   const annotation = annotations[0];
   expect(annotation.selector).toEqual('my-hero-detail');
 });
开发者ID:MarkPieszak,项目名称:angular,代码行数:8,代码来源:static_reflector_spec.ts

示例5: it

    it('should allow inheritance from functions', () => {
      initWithDecorator({
        '/tmp/src/main.ts': `
            export let ctor: {new(): T} = function() { return null; }
            export class Child extends ctor {}
          `
      });

      expect(reflector.annotations(reflector.getStaticSymbol('/tmp/src/main.ts', 'Child')))
          .toEqual([]);
    });
开发者ID:diestrin,项目名称:angular,代码行数:11,代码来源:static_reflector_spec.ts


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