ngParty / ng-metadata

Angular 2 decorators and utils for Angular 1.x

Home Page:https://hotell.gitbooks.io/ng-metadata/content/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tsc error when building locally, conflict with AngularJs typings

mtraynham opened this issue · comments

I've come across this because of a change in a typing from DefinitelyTyped to AngularJS LN1980. This new typing conflicts with source code presently in ng-metadata-src/core/directives/metadata-directives.

node_modules/ng-metadata/src/core/directives/metadata_directives.d.ts(16,15): error TS2314: Generic type 'IDirectiveCompileFn<TScope>' requires 1 type argument(s).

I actually import this module, ng-metadata/src/core/directives/metadata_directives, so that I can use those decorator features to generate a component template. When two libraries conflict like this, TypeScript hasn't really suggested a good solution for external conflicts 1 .

Although, I could swing a few ways for a solution, I believe the most appropriate resolution is to update this project's typings.

Thanks for the report. In my mind the scope type should be optional in the angular type definition and not break downstream type usage.

Updating ng-metadata's types would probably be good but people would have to use @types/angular@^1.6.38

I buy that as well, but does TypeScript support optional generic typings?

So it does, that PR just didn't do it for all of them...

    interface IDirectiveCompileFn<TScope extends IScope = IScope> {

I'll submit a PR to DefinitelyTyped and link back here

Merged up and seems fixed, so am closing. Thanks again for the feedback @aciccarello!