Commit Graph

101 Commits

Author SHA1 Message Date
Evan Martin
8002c111c6 accept Window as argument to JQueryStatic (#37567)
Users write code like:
  angular.element(window)
  angular.element($window)  // IWindowService

but this fails with a type error under TypeScript 3.5, due to a change
in the type of of Window.  (Previously the only reason it compiled is
that Window was matching the ArrayLike<Element> param.)

Note that if you run the tests, the definition of JQueryStatic here
in the JQLite typings declaration-merges with the full JQuery
definition, which accepts any (!) so there is no type error.  But if
you use just this library without JQuery, the type errors without my
fix look like:

angular-tests.ts:788:17 - error TS2345: Argument of type 'Window' is not assignable to parameter of type 'string | Element | Document | JQuery | ArrayLike<Element> | (() => void)'.
  Type 'Window' is missing the following properties from type 'Document': activeElement, alinkColor, all, anchors, and 147 more.

788 angular.element(window);
                    ~~~~~~

angular-tests.ts:790:17 - error TS2345: Argument of type 'IWindowService' is not assignable to parameter of type 'string | Element | Document | JQuery | ArrayLike<Element> | (() => void)'.
  Type 'IWindowService' is missing the following properties from type 'Document': activeElement, alinkColor, all, anchors, and 147 more.
2019-08-12 14:36:54 -07:00
chivesrs
9bbed9600f Add typings for jQuery custom event into jqLite (#36735) 2019-07-09 16:30:18 -07:00
Martin Probst
970fc9d484 Angular IPromise interop with platform Promise.
Angular promises support `.then()` chaining of functions that return
arbitrary `then()`able values.
    https://docs.angularjs.org/api/ng/service/$q#the-promise-api

This change updates the definition of `ng.IPromise.then()` to match that
by overloading the function to handle `PromiseLike` values.
2019-02-06 14:08:06 +01:00
Oscar Busk
e84be5f370
Merge branch 'master' of github.com:oBusk/DefinitelyTyped into fix-jquery-2-events 2018-12-19 21:59:38 +01:00
Quentin Bouygues
f5ec4969d0 test only directive function using custom types for link function 2018-12-17 10:13:25 +01:00
Quentin Bouygues
443d1cdc32 Add tests for directive generics 2018-12-17 10:00:24 +01:00
Quentin Bouygues
d158d782e9 Test IDirective changes,
cascade generics from IModule's directive function
2018-12-14 17:21:44 +01:00
Quentin Bouygues
7983723f0f Update Directive typings to enable type checking with TS compiler's strict mode
With TypeScript's flag `strictFunctionTypes`, the directive type needs to accept subtypes of its current arguments, and cascade them to its function.
This commit adds it using cascading generics on all the related types
2018-12-14 11:53:02 +01:00
oBusk
a1f4f7ac19 Add deprecated to which in jqlite 2018-12-12 13:10:56 +01:00
oBusk
3f1adde0d0 Add deprecated to char, charCode and keyCode in jqlite 2018-12-12 12:46:40 +01:00
oBusk
45903423f3 add types to event key and char in jqlite 2018-12-12 12:46:14 +01:00
Leonard Thieu
acc34c5a23 [angular] Update merging tests for jQuery Events API changes. 2018-11-24 09:43:04 -05:00
barrtender
58d87fc9d4 Fixing ICacheObject::get return type (#29001)
get can return undefined if the key isn't in the cache.

See the example:
https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache
```
  superCache.remove('another key');
  expect(superCache.get('another key')).toBeUndefined();
```
2018-09-18 15:24:08 -07:00
Geoff Cameron
ddb90ccfe1 Add tests 2018-08-13 14:18:26 -04:00
Geoff Cameron
322c5e6cad Use real promise base class 2018-08-03 19:34:11 -04:00
Geoff Cameron
a8486a33ea Make typings compatible with ES6 promises
Since ES6 promises don't implement finally, trying to $q.when a third
party promises fails typings. This introduces a new type that is
compatible with this, to allow for typings to work when
taking an ES6 promise.

Totally willing to change the name to something more sensible here
2018-08-02 15:40:03 -04:00
Andy
57ed6e767c
angular: Fix test (#27778) 2018-08-02 08:06:17 -07:00
Richie Foreman
1aa8a708ac Add types for $injector.{loadNewModules, modules} to types/angular (#27240)
* Add {loadNewModules, modules} to angular.auto.IInjectorService

* Add {loadNewModules, modules} to angular.auto.IInjectorService

* Allow for annotated functions in .loadNewModules()

* Fix Injectable Type

* Add useful docstrings (which are pretty much carbon copied from the Angular docs)

* I dont see any whitespace, but travis does.. remove junk

* more

* Add {loadNewModules, modules} to angular.auto.IInjectorService
2018-07-20 17:34:05 -07:00
Oscar Busk
4ef49ba480 Simplify filterfunction using interface instead of silly type 2018-06-28 22:21:06 +02:00
Oscar Busk
f6a902f8ce Improve module.filter() by allowing $stateful to be defined. 2018-06-28 12:27:49 +02:00
Mine Starks
c01777fef8
Merge pull request #26321 from scipper/master
Added new featured to $rootScope from 1.6.10
2018-06-13 08:36:15 -07:00
Lucas Sloan
8dfa12287e Make the IControllerService typings more specific.
Tighten the IControllerService typings by replacing the generic Function type with the more specific (...args: any[]) => T, which specifies a function which returns a generic type matching the controller required.
2018-06-07 13:23:10 -07:00
Steffen Kowalski
ce7505a1d1 fixed errors in @types/angular 2018-06-07 09:31:07 +02:00
Steffen Kowalski
ef970e72ad
added docs to $suspend, $isSuspended and $resume 2018-06-06 15:27:16 +02:00
Steffen Kowalski
43448845ed
Added myself to "Definitions by" 2018-06-06 14:14:35 +02:00
Steffen Kowalski
faa9a6b089
Added new featured to $rootScope from 1.6.10
https://github.com/angular/angular.js/blob/master/CHANGELOG.md#1610-crystalline-persuasion-2018-04-17
2018-06-06 14:13:31 +02:00
Lucas Sloan
2689160921 AngularJS: improve types for IQService.all (support for arrays of non-promises). (#25350) 2018-05-03 10:53:09 -07:00
Oscar Busk
f4e0c531ba Add typing for object syntax on component registerer (#25507) 2018-05-03 10:51:31 -07:00
Daniel Rosenwasser
47e802c56c
Merge pull request #23517 from thorn0/angular-foreach-array-likes
AngularJS: improve types for `foreach` (support for array-likes)
2018-02-15 12:50:30 -08:00
Andy Hanson
45c9246c09 Remove esModuleInterop from tsconfigs (no longer mandatory) 2018-02-14 14:55:13 -08:00
Georgii Dolzhykov
628cbd69e1 AngularJS: improve types for foreach (support for array-likes) 2018-02-08 20:50:26 +02:00
Andy
bef4d2b27d
Enable "esModuleInterop" in all tsconfigs (#23354) 2018-02-05 11:01:56 -08:00
Georgii Dolzhykov
50ae629d0c AngularJS: rename confusing identifiers in tests (#23314) 2018-01-31 14:44:50 -08:00
Georgii Dolzhykov
37c1b1dfea AngularJS: 1) fix for $q.reject in then callbacks, 2) types for $error and $pending (#23115)
* AngularJS: 1) fix an issue with $q.reject in then callbacks, 2) types for $error and $pending

Fixes #21333

* Promise typings from lib.d.ts + IPromise<never> hack
2018-01-29 12:12:25 -08:00
Benjamin Buhler
4c23e96fc7 Added $processModelValue to INgModelController (#23128)
See https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#$processModelValue
2018-01-23 15:03:32 -08:00
Andy
219dd6df82
Fix 'prefer-readonly' lint failures (#22819) 2018-01-10 14:59:37 -08:00
Robin Keller
25bf971c33 Update angular.module to accept an Injectable as the configFn.
This is undocumented behavior in Angular, but works because this argument is passed to $injector.invoke.
See 49aba51e6b/src/loader.js lines 81, 370, and 111
2017-12-21 13:03:39 -08:00
Andy
30957ad3d8
Remove // tslint:disable comments (#22198) 2017-12-14 13:24:24 -08:00
mtraynham
7f84ba072d Add optional generic typing test for Angular IDirectiveCompileFn 2017-11-06 11:55:05 -05:00
mtraynham
bcf7644868 Angular - Default IScope generic typings for backwards compatibility 2017-11-06 11:34:28 -05:00
Daniel Rosenwasser
40d6bf0abd
Merge pull request #21209 from fjmorel/master
angular: Add missing function to ICompileProvider
2017-11-04 01:35:10 -07:00
Fred Morel
20240a4128 Add strictComponentBindingsEnabled to ICompileProvider
Function added in angular 1.6.x
2017-11-02 16:12:59 -04:00
Georgii Dolzhykov
44e215bda7 AngularJS: compatibility with strictFunctionTypes
Fixes #21160
2017-11-01 15:13:22 +03:00
ohze.net
8a6a758e90 add angular.element(callback) (#21011)
see document for `ready()` method at https://docs.angularjs.org/api/ng/function/angular.element#angularjs-s-jqlite
2017-10-26 11:46:09 -07:00
Andy
097d2acf71 Miscellaneous lint fixes (#20849) 2017-10-22 15:22:50 -07:00
aidandownes
0b0c6b20b0 Update type definition for $injector.invoke to be consistent with angular documentation/code. (#19886)
- $inject.invoke also accepts optional context and locals agruments when function is an array annotation format.
- Also added tests.
2017-10-16 09:06:56 -07:00
Elijah Schow
ec2c36e82b Add `$overrideModelOptions' to 'INgModelController' (closes #19136) (#19880)
AngularJS Issue:
https://github.com/angular/angular.js/issues/12884

AngularJS Documentation:
https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#$overrideModelOptions

AngularJS Source:
https://github.com/angular/angular.js/blob/master/src/ng/directive/ngModel.js#L863
2017-10-16 09:04:19 -07:00
Andy
947a8fb761 Enable strictFunctionTypes (#20373) 2017-10-06 14:03:03 -07:00
Andy Hanson
56c69546dd angular: Fix tests 2017-10-03 07:28:01 -07:00
oscar_busk
9d409aeadc Angular: add comment about debugInfo on scope()
Add a comment explaining that the scope() and isolatedScope() methods
requires debugInfoEnabled(true) to return the $scope.
2017-08-23 22:10:51 +02:00