-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): create angular typings override so we don't have to impor…
…t them to source - bump to typescript@next which resolves issues with type declaration generation - extract angular module type overrides to separate file which should by included within consumer app - make global.d.ts truly global - use only ng.* namespace for types ( no angular ) - update tsconfig to make tsc faster, stronger ;) - fix compile errors introduced by latest ts 2.1 with better any type inference - fix NgModule decorator options types to properly allow registering downgraded ng2 entities Closes #175, #177 BREAKING CHANGE: We now officialy support only angular typings provided via npm `@types/*` and also typescript 2.x - your existing typings provided by `typings` might not work - from now on if you wanna use deprecated `provide` function from `ng-metadata/core` with registration within `angular.module().directive|service|filter` you have to explicitly include angular types extension provided by ng-metadata from `node_modules/ng-metadata/manual_typings/angular-extension.d.ts` Before: ```typescript // global.d.ts /// <reference path="../node_modules/ng-metadata/manual_typings/globals.d.ts" /> ``` After: ```typescript /// <reference path="../node_modules/ng-metadata/manual_typings/angular-extension.d.ts" /> ``` or you can include it from within your tsconfig.json like this: ```json { "include":[ "src/**/*.ts" ], "files": [ "node_modules/ng-metadata/manual_typings/angular-extension.d.ts" ], "exclude": [ "node_modules" ] } ```
- Loading branch information
Showing
19 changed files
with
2,171 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/// <reference types="angular" /> | ||
|
||
import * as angular from 'angular'; | ||
|
||
type ProvideSpreadType = string|Function; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// ngMetadata angular module overrides | ||
// - add angular1 module overrides for proper ...provide handling | ||
/////////////////////////////////////////////////////////////////////////////// | ||
declare module 'angular' { | ||
interface IParseService{ | ||
( exp: string, interceptorFn?: Function, expensiveChecks?: boolean ): ICompiledExpression | ||
} | ||
interface IModule { | ||
value(...args: ProvideSpreadType[]): IModule; | ||
constant(...args: ProvideSpreadType[]): IModule; | ||
directive(...args: ProvideSpreadType[]): IModule; | ||
filter(...args: ProvideSpreadType[]): IModule; | ||
service(...args: ProvideSpreadType[]): IModule; | ||
provider(...args: ProvideSpreadType[]): IModule; | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
// AUTO module (angular.js) | ||
/////////////////////////////////////////////////////////////////////////// | ||
export module auto { | ||
|
||
/////////////////////////////////////////////////////////////////////// | ||
// ProvideService | ||
// see http://docs.angularjs.org/api/AUTO.$provide | ||
/////////////////////////////////////////////////////////////////////// | ||
interface IProvideService { | ||
// Documentation says it returns the registered instance, but actual | ||
// implementation does not return anything. | ||
// constant(name: string, value: any): any; | ||
/** | ||
* Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. | ||
*/ | ||
constant(...args: ProvideSpreadType[]): void; | ||
|
||
/** | ||
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. | ||
* | ||
* @param name The name of the service to decorate. | ||
* @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: | ||
* | ||
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. | ||
*/ | ||
//decorator(name: string, decorator: Function): void; | ||
/** | ||
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. | ||
* | ||
* @param name The name of the service to decorate. | ||
* @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: | ||
* | ||
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. | ||
*/ | ||
//decorator(name: string, inlineAnnotatedFunction: any[]): void; | ||
factory(...args: ProvideSpreadType[]): IServiceProvider; | ||
provider(...args: ProvideSpreadType[]): IServiceProvider; | ||
service(...args: ProvideSpreadType[]): IServiceProvider; | ||
value(...args: ProvideSpreadType[]): IServiceProvider; | ||
} | ||
|
||
} | ||
|
||
// /** | ||
// * $rootScope - $rootScopeProvider - service in module ng | ||
// * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope | ||
// */ | ||
// interface IRootScopeService { | ||
// | ||
// // private members | ||
// $$postDigest( callback: Function ): void, | ||
// $$postDigestQueue: Function[], | ||
// $$applyAsyncQueue: Function[], | ||
// $$asyncQueue: Function[], | ||
// $$watchers: Watchers[], | ||
// $$watchersCount: number, | ||
// $$listenerCount: Object, | ||
// $$listeners: Object, | ||
// $$destroyed: boolean, | ||
// $$childHead: ng.IScope, | ||
// $$childTail: ng.IScope, | ||
// $$prevSibling: ng.IScope, | ||
// $$nextSibling: ng.IScope, | ||
// | ||
// // ngMetadata private members | ||
// $$disconnected?: boolean, | ||
// | ||
// } | ||
// | ||
// /* @private */ | ||
// interface Watchers { | ||
// eq: boolean, | ||
// exp: ( s: any, l: any, a: any, i: any ) => any, | ||
// fn: ( newValue: any, oldValue: any ) => any, | ||
// get: ( s: any, l: any, a: any, i: any ) => any, | ||
// last: any | ||
// } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1 @@ | ||
import * as angular from 'angular'; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// functions attached to global object (window) | ||
/////////////////////////////////////////////////////////////////////////////// | ||
declare global { | ||
type StringMap = {[key: string]: string}; | ||
type ProvideSpreadType = string|Function; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// custom angular module overrides | ||
// - add angular1 module overrides for proper ...provide handling | ||
/////////////////////////////////////////////////////////////////////////////// | ||
declare module 'angular' { | ||
interface IParseService{ | ||
( exp: string, interceptorFn?: Function, expensiveChecks?: boolean ): ng.ICompiledExpression | ||
} | ||
interface IModule { | ||
value(...args: ProvideSpreadType[]): IModule; | ||
constant(...args: ProvideSpreadType[]): IModule; | ||
directive(...args: ProvideSpreadType[]): IModule; | ||
filter(...args: ProvideSpreadType[]): IModule; | ||
service(...args: ProvideSpreadType[]): IModule; | ||
provider(...args: ProvideSpreadType[]): IModule; | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
// AUTO module (angular.js) | ||
/////////////////////////////////////////////////////////////////////////// | ||
export module auto { | ||
|
||
/////////////////////////////////////////////////////////////////////// | ||
// ProvideService | ||
// see http://docs.angularjs.org/api/AUTO.$provide | ||
/////////////////////////////////////////////////////////////////////// | ||
interface IProvideService { | ||
// Documentation says it returns the registered instance, but actual | ||
// implementation does not return anything. | ||
// constant(name: string, value: any): any; | ||
/** | ||
* Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. | ||
*/ | ||
constant(...args: ProvideSpreadType[]): void; | ||
|
||
/** | ||
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. | ||
* | ||
* @param name The name of the service to decorate. | ||
* @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: | ||
* | ||
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. | ||
*/ | ||
//decorator(name: string, decorator: Function): void; | ||
/** | ||
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. | ||
* | ||
* @param name The name of the service to decorate. | ||
* @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: | ||
* | ||
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. | ||
*/ | ||
//decorator(name: string, inlineAnnotatedFunction: any[]): void; | ||
factory(...args: ProvideSpreadType[]): IServiceProvider; | ||
provider(...args: ProvideSpreadType[]): IServiceProvider; | ||
service(...args: ProvideSpreadType[]): IServiceProvider; | ||
value(...args: ProvideSpreadType[]): IServiceProvider; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* $rootScope - $rootScopeProvider - service in module ng | ||
* see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope | ||
*/ | ||
interface IRootScopeService { | ||
|
||
// private members | ||
$$postDigest( callback: Function ): void, | ||
$$postDigestQueue: Function[], | ||
$$applyAsyncQueue: Function[], | ||
$$asyncQueue: Function[], | ||
$$watchers: Watchers[], | ||
$$watchersCount: number, | ||
$$listenerCount: Object, | ||
$$listeners: Object, | ||
$$destroyed: boolean, | ||
$$childHead: IScope, | ||
$$childTail: IScope, | ||
$$prevSibling: IScope, | ||
$$nextSibling: IScope, | ||
|
||
// ngMetadata private members | ||
$$disconnected?: boolean, | ||
|
||
} | ||
|
||
/* @private */ | ||
interface Watchers { | ||
eq: boolean, | ||
exp: ( s: any, l: any, a: any, i: any ) => any, | ||
fn: ( newValue: any, oldValue: any ) => any, | ||
get: ( s: any, l: any, a: any, i: any ) => any, | ||
last: any | ||
} | ||
|
||
} | ||
type StringMap = {[key: string]: string}; |
Oops, something went wrong.