Skip to content

Commit

Permalink
fix(manual_typings): make custom global angular overrides work with b…
Browse files Browse the repository at this point in the history
…oth global and module type definitions (#167)

- now it will work for both type defs for angular ( from typings or from npm @types/angular )
- ofc you can use just one not both types from typings and @types/angular
- if you are using @types you have to introduce within your tests `import * as angular from 'angular'` to be able to do `angular.mock....`, angular is no longer exposed on global

* fix(manual_typings): revert auto from namespace back to module
  • Loading branch information
Hotell authored Oct 20, 2016
1 parent aaabe30 commit 3eb047d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
20 changes: 15 additions & 5 deletions manual_typings/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
declare type StringMap = {[key:string]:string};
declare type Type = Function;
declare type ProvideSpreadType = string|Type;
import * as angular from 'angular';

// @TODO add angular1 module overrides for proper ...provide handling
declare module angular {
///////////////////////////////////////////////////////////////////////////////
// functions attached to global object (window)
///////////////////////////////////////////////////////////////////////////////
declare global {
type StringMap = {[key: string]: string};
type Type = Function;
type ProvideSpreadType = string|Type;
}

///////////////////////////////////////////////////////////////////////////////
// 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
}
Expand Down
3 changes: 2 additions & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as angular from 'angular';
import { isArray, isFunction, assign } from '../src/facade/lang';

// ============================
Expand Down Expand Up @@ -117,7 +118,7 @@ function __injectionArgs(fn, locals, serviceName){
* @internal
* @returns {any}
*/
export function getNg1InjectorMock(): ng.auto.IInjectorService {
export function getNg1InjectorMock(): angular.auto.IInjectorService {
return {
instantiate( classFactory ){
return new classFactory();
Expand Down

0 comments on commit 3eb047d

Please sign in to comment.