question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parent and Ancestor annotations in typescript

See original GitHub issue

the equivalent of the following in dart works perfectly, in typescript after defining the Parent and the Ancestor annotations in typescript typings as:

declare module "angular2/annotations"{
   function Parent():(target: Type) => any;
   function Ancestor():(target: Type) => any;
}```

And using it as:

```typescript
/// <reference path="typings/angular2/angular2.d.ts" />
import {bootstrap, Component, View} from 'angular2/angular2';
import {Parent} from 'angular2/annotations'

@Component({selector:"c2"})
@View({template:'i am c2'})
class C2{
   constructor(@Parent() p:C1){
      console.log(p);
   }
}

@Component({selector:"c1"})
@View({template:`<c2></c2>`,directives:[C2]})
class C1{}

@Component({selector:"app"})
@View({template:`<c1></c1>`, directives:[C1]})
class App{}

bootstrap(App);

it throws:

TypeError: Cannot read property 'length' of undefined

TypeError: Cannot read property 'length' of undefined
    at ReflectionCapabilities.execute.ReflectionCapabilities._zipTypesAndAnnotaions (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:6620:64)
    at ReflectionCapabilities.execute.ReflectionCapabilities.parameters (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:6641:29)
    at Reflector.execute.Reflector.parameters (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:16282:50)
    at _dependenciesFor (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:16989:28)
    at execute.Binding.resolve (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:17122:28)
    at Function.execute.DirectiveBinding.createFromBinding (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:23681:24)
    at Function.execute.DirectiveBinding.createFromType (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:23687:37)
    at Compiler.execute.Compiler._bindDirective (https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:24947:39)
    at https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js:24992:29
   ...

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
neokeatscommented, Jun 19, 2015

@mhevery since we are tracking it else where.

it would be nice to reference it, not just closing like that…

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parent and Ancestor annotation in ts - angular
Trying to add the Parent and Ancestor annotations to TypeScript typings so I did: declare module "angular2/src/core/annotations_impl/visibility"{ function ...
Read more >
TypeScript Inheritance
The class which inherits properties and methods is called the child class. And the class whose properties and methods are inherited is known...
Read more >
Consider inferring class members types by implemented ...
A. Start by inheriting type from the ancestor classes: If the type of the property/method name was explicitly defined in an ancestor class, ......
Read more >
TypeScript: Documentation - Classes
Constructors can't have return type annotations - the class instance type is always what's returned. Super Calls. Just as in JavaScript, if you...
Read more >
Learn how to unleash the full potential of the type system ...
I realize that this complexity may be required to gradually convert a 'worst case' Javascript code base into 'correct' Typescript, but IMHO most ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found