Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old provide syntax not working for directives #175

Closed
vwochnik opened this issue Nov 9, 2016 · 2 comments
Closed

Old provide syntax not working for directives #175

vwochnik opened this issue Nov 9, 2016 · 2 comments
Labels

Comments

@vwochnik
Copy link

vwochnik commented Nov 9, 2016

The deprecated syntax for registering a directive using provide is not working, because there is a type mismatch.

This is how it was supposed to work:

import * as angular from 'angular';
import { Component, provide } from 'ng-metadata/core';

@Component({
  selector: 'hero',
  template: 'An angular 2 hero tag!'
})
export class HeroComponent {

  constructor(){

  }

}

angular.module('myApp')
  .directive( ...provide(HeroComponent) );

And this is the error:

test.ts(18,1): error TS2346: Supplied parameters do not match any signature of call target.

I tried getting more detailed information:

angular.module('myApp')
  .directive( "hero", provide(HeroComponent)[1] );

And here is the result:

test.ts(19,23): error TS2345: Argument of type 'Function | Type' is not assignable to parameter of type 'Injectable<IDirectiveFactory>'.
  Type 'Function' is not assignable to type 'Injectable<IDirectiveFactory>'.
    Type 'Function' is not assignable to type '(string | IDirectiveFactory)[]'.
      Property 'push' is missing in type 'Function'.

And here ends my expertise with TypeScript. I an choosing the old syntax for now because I want to get started without setting up an index.ts for our existing application.

@aciccarello
Copy link
Collaborator

I get a similar error message in my editor (VS Code) but it does not seem to affect my webpack build. I'm using TypeScript 2.0 but am still using Typings (not @types)

@Hotell
Copy link
Member

Hotell commented Nov 9, 2016

there is a quick fix for that

add this to your global.d.ts

/// <reference path="../node_modules/ng-metadata/manual_typings/globals.d.ts" />

@Hotell Hotell added the bug label Nov 9, 2016
@Hotell Hotell closed this as completed in 3153bca Nov 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants