ember-source 4.4.0-alpha.2 → 4.4.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/build-metadata.json +3 -3
  2. package/dist/ember-template-compiler.js +8 -5
  3. package/dist/ember-template-compiler.map +1 -1
  4. package/dist/ember-testing.js +2 -2
  5. package/dist/ember-testing.map +1 -1
  6. package/dist/ember.debug.js +692 -583
  7. package/dist/ember.debug.map +1 -1
  8. package/dist/header/license.js +1 -1
  9. package/dist/packages/@ember/-internals/glimmer/index.js +37 -4
  10. package/dist/packages/@ember/-internals/metal/index.js +5 -13
  11. package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -1
  12. package/dist/packages/@ember/-internals/routing/lib/services/router.js +65 -12
  13. package/dist/packages/@ember/-internals/routing/lib/system/route.js +1 -1
  14. package/dist/packages/@ember/-internals/routing/lib/system/router.js +10 -7
  15. package/dist/packages/@ember/-internals/runtime/lib/compare.js +19 -5
  16. package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
  17. package/dist/packages/@ember/canary-features/index.js +4 -2
  18. package/dist/packages/@ember/debug/lib/handlers.js +1 -1
  19. package/dist/packages/@ember/runloop/index.js +31 -528
  20. package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +5 -0
  21. package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +59 -0
  22. package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +5 -0
  23. package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +77 -0
  24. package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +38 -0
  25. package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +38 -0
  26. package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +38 -0
  27. package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +38 -0
  28. package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +38 -0
  29. package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +39 -0
  30. package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +39 -0
  31. package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +77 -0
  32. package/dist/packages/ember/index.js +1 -0
  33. package/dist/packages/ember/version.js +1 -1
  34. package/docs/data.json +203 -102
  35. package/package.json +2 -2
@@ -11,7 +11,7 @@ function onBegin(current) {
11
11
  currentRunLoop = current;
12
12
  }
13
13
 
14
- function onEnd(current, next) {
14
+ function onEnd(_current, next) {
15
15
  currentRunLoop = next;
16
16
  flushAsyncObservers();
17
17
  }
@@ -50,157 +50,14 @@ export const _backburner = new Backburner(_queues, {
50
50
  onErrorMethod: 'onerror',
51
51
  flush
52
52
  });
53
- /**
54
- @module @ember/runloop
55
- */
56
- // ..........................................................
57
- // run - this is ideally the only public API the dev sees
58
- //
59
-
60
- /**
61
- Runs the passed target and method inside of a RunLoop, ensuring any
62
- deferred actions including bindings and views updates are flushed at the
63
- end.
64
-
65
- Normally you should not need to invoke this method yourself. However if
66
- you are implementing raw event handlers when interfacing with other
67
- libraries or plugins, you should probably wrap all of your code inside this
68
- call.
69
-
70
- ```javascript
71
- import { run } from '@ember/runloop';
72
-
73
- run(function() {
74
- // code to be executed within a RunLoop
75
- });
76
- ```
77
- @method run
78
- @for @ember/runloop
79
- @static
80
- @param {Object} [target] target of method to call
81
- @param {Function|String} method Method to invoke.
82
- May be a function or a string. If you pass a string
83
- then it will be looked up on the passed target.
84
- @param {Object} [args*] Any additional arguments you wish to pass to the method.
85
- @return {Object} return value from invoking the passed function.
86
- @public
87
- */
88
-
89
- export function run() {
90
- return _backburner.run(...arguments);
53
+ export function run(...args) {
54
+ // @ts-expect-error TS doesn't like our spread args
55
+ return _backburner.run(...args);
91
56
  }
92
- /**
93
- If no run-loop is present, it creates a new one. If a run loop is
94
- present it will queue itself to run on the existing run-loops action
95
- queue.
96
-
97
- Please note: This is not for normal usage, and should be used sparingly.
98
-
99
- If invoked when not within a run loop:
100
-
101
- ```javascript
102
- import { join } from '@ember/runloop';
103
-
104
- join(function() {
105
- // creates a new run-loop
106
- });
107
- ```
108
-
109
- Alternatively, if called within an existing run loop:
110
-
111
- ```javascript
112
- import { run, join } from '@ember/runloop';
113
-
114
- run(function() {
115
- // creates a new run-loop
116
-
117
- join(function() {
118
- // joins with the existing run-loop, and queues for invocation on
119
- // the existing run-loops action queue.
120
- });
121
- });
122
- ```
123
-
124
- @method join
125
- @static
126
- @for @ember/runloop
127
- @param {Object} [target] target of method to call
128
- @param {Function|String} method Method to invoke.
129
- May be a function or a string. If you pass a string
130
- then it will be looked up on the passed target.
131
- @param {Object} [args*] Any additional arguments you wish to pass to the method.
132
- @return {Object} Return value from invoking the passed function. Please note,
133
- when called within an existing loop, no return value is possible.
134
- @public
135
- */
136
-
137
- export function join() {
138
- return _backburner.join(...arguments);
57
+ export function join(methodOrTarget, methodOrArg, ...additionalArgs) {
58
+ return _backburner.join(methodOrTarget, methodOrArg, ...additionalArgs);
139
59
  }
140
- /**
141
- Allows you to specify which context to call the specified function in while
142
- adding the execution of that function to the Ember run loop. This ability
143
- makes this method a great way to asynchronously integrate third-party libraries
144
- into your Ember application.
145
-
146
- `bind` takes two main arguments, the desired context and the function to
147
- invoke in that context. Any additional arguments will be supplied as arguments
148
- to the function that is passed in.
149
-
150
- Let's use the creation of a TinyMCE component as an example. Currently,
151
- TinyMCE provides a setup configuration option we can use to do some processing
152
- after the TinyMCE instance is initialized but before it is actually rendered.
153
- We can use that setup option to do some additional setup for our component.
154
- The component itself could look something like the following:
155
-
156
- ```app/components/rich-text-editor.js
157
- import Component from '@ember/component';
158
- import { on } from '@ember/object/evented';
159
- import { bind } from '@ember/runloop';
160
-
161
- export default Component.extend({
162
- initializeTinyMCE: on('didInsertElement', function() {
163
- tinymce.init({
164
- selector: '#' + this.$().prop('id'),
165
- setup: bind(this, this.setupEditor)
166
- });
167
- }),
168
-
169
- didInsertElement() {
170
- tinymce.init({
171
- selector: '#' + this.$().prop('id'),
172
- setup: bind(this, this.setupEditor)
173
- });
174
- }
175
-
176
- setupEditor(editor) {
177
- this.set('editor', editor);
178
-
179
- editor.on('change', function() {
180
- console.log('content changed!');
181
- });
182
- }
183
- });
184
- ```
185
-
186
- In this example, we use `bind` to bind the setupEditor method to the
187
- context of the RichTextEditor component and to have the invocation of that
188
- method be safely handled and executed by the Ember run loop.
189
-
190
- @method bind
191
- @static
192
- @for @ember/runloop
193
- @param {Object} [target] target of method to call
194
- @param {Function|String} method Method to invoke.
195
- May be a function or a string. If you pass a string
196
- then it will be looked up on the passed target.
197
- @param {Object} [args*] Any additional arguments you wish to pass to the method.
198
- @return {Function} returns a new function that will always have a particular context
199
- @since 1.4.0
200
- @public
201
- */
202
-
203
- export const bind = (...curried) => {
60
+ export function bind(...curried) {
204
61
  assert('could not find a suitable method to bind', function (methodOrTarget, methodOrArg) {
205
62
  // Applies the same logic as backburner parseArgs for detecting if a method
206
63
  // is actually being passed.
@@ -211,15 +68,16 @@ export const bind = (...curried) => {
211
68
  } else if (length === 1) {
212
69
  return typeof methodOrTarget === 'function';
213
70
  } else {
214
- let type = typeof methodOrArg;
215
- return type === 'function' || // second argument is a function
216
- methodOrTarget !== null && type === 'string' && methodOrArg in methodOrTarget || // second argument is the name of a method in first argument
71
+ return typeof methodOrArg === 'function' || // second argument is a function
72
+ methodOrTarget !== null && typeof methodOrArg === 'string' && methodOrArg in methodOrTarget || // second argument is the name of a method in first argument
217
73
  typeof methodOrTarget === 'function' //first argument is a function
218
74
  ;
219
- }
220
- }(...curried));
75
+ } // @ts-expect-error TS doesn't like our spread args
76
+
77
+ }(...curried)); // @ts-expect-error TS doesn't like our spread args
78
+
221
79
  return (...args) => join(...curried.concat(args));
222
- };
80
+ }
223
81
  /**
224
82
  Begins a new RunLoop. Any deferred actions invoked after the begin will
225
83
  be buffered until you invoke a matching call to `end()`. This is
@@ -266,52 +124,9 @@ export function begin() {
266
124
  export function end() {
267
125
  _backburner.end();
268
126
  }
269
- /**
270
- Adds the passed target/method and any optional arguments to the named
271
- queue to be executed at the end of the RunLoop. If you have not already
272
- started a RunLoop when calling this method one will be started for you
273
- automatically.
274
-
275
- At the end of a RunLoop, any methods scheduled in this way will be invoked.
276
- Methods will be invoked in an order matching the named queues defined in
277
- the `queues` property.
278
-
279
- ```javascript
280
- import { schedule } from '@ember/runloop';
281
-
282
- schedule('afterRender', this, function() {
283
- // this will be executed in the 'afterRender' queue
284
- console.log('scheduled on afterRender queue');
285
- });
286
-
287
- schedule('actions', this, function() {
288
- // this will be executed in the 'actions' queue
289
- console.log('scheduled on actions queue');
290
- });
291
-
292
- // Note the functions will be run in order based on the run queues order.
293
- // Output would be:
294
- // scheduled on actions queue
295
- // scheduled on afterRender queue
296
- ```
297
-
298
- @method schedule
299
- @static
300
- @for @ember/runloop
301
- @param {String} queue The name of the queue to schedule against. Default queues is 'actions'
302
- @param {Object} [target] target object to use as the context when invoking a method.
303
- @param {String|Function} method The method to invoke. If you pass a string it
304
- will be resolved on the target object at the time the scheduled item is
305
- invoked allowing you to change the target function.
306
- @param {Object} [arguments*] Optional arguments to be passed to the queued method.
307
- @return {*} Timer information for use in canceling, see `cancel`.
308
- @public
309
- */
310
-
311
- export function
312
- /* queue, target, method */
313
- schedule() {
314
- return _backburner.schedule(...arguments);
127
+ export function schedule(...args) {
128
+ // @ts-expect-error TS doesn't like the rest args here
129
+ return _backburner.schedule(...args);
315
130
  } // Used by global test teardown
316
131
 
317
132
  export function _hasScheduledTimers() {
@@ -321,214 +136,19 @@ export function _hasScheduledTimers() {
321
136
  export function _cancelTimers() {
322
137
  _backburner.cancelTimers();
323
138
  }
324
- /**
325
- Invokes the passed target/method and optional arguments after a specified
326
- period of time. The last parameter of this method must always be a number
327
- of milliseconds.
328
-
329
- You should use this method whenever you need to run some action after a
330
- period of time instead of using `setTimeout()`. This method will ensure that
331
- items that expire during the same script execution cycle all execute
332
- together, which is often more efficient than using a real setTimeout.
333
-
334
- ```javascript
335
- import { later } from '@ember/runloop';
336
-
337
- later(myContext, function() {
338
- // code here will execute within a RunLoop in about 500ms with this == myContext
339
- }, 500);
340
- ```
341
-
342
- @method later
343
- @static
344
- @for @ember/runloop
345
- @param {Object} [target] target of method to invoke
346
- @param {Function|String} method The method to invoke.
347
- If you pass a string it will be resolved on the
348
- target at the time the method is invoked.
349
- @param {Object} [args*] Optional arguments to pass to the timeout.
350
- @param {Number} wait Number of milliseconds to wait.
351
- @return {*} Timer information for use in canceling, see `cancel`.
352
- @public
353
- */
354
-
355
- export function
356
- /*target, method*/
357
- later() {
358
- return _backburner.later(...arguments);
139
+ export function later(...args) {
140
+ return _backburner.later(...args);
359
141
  }
360
- /**
361
- Schedule a function to run one time during the current RunLoop. This is equivalent
362
- to calling `scheduleOnce` with the "actions" queue.
363
-
364
- @method once
365
- @static
366
- @for @ember/runloop
367
- @param {Object} [target] The target of the method to invoke.
368
- @param {Function|String} method The method to invoke.
369
- If you pass a string it will be resolved on the
370
- target at the time the method is invoked.
371
- @param {Object} [args*] Optional arguments to pass to the timeout.
372
- @return {Object} Timer information for use in canceling, see `cancel`.
373
- @public
374
- */
375
-
376
142
  export function once(...args) {
377
- args.unshift('actions');
378
- return _backburner.scheduleOnce(...args);
143
+ // @ts-expect-error TS doesn't like the rest args here
144
+ return _backburner.scheduleOnce('actions', ...args);
379
145
  }
380
- /**
381
- Schedules a function to run one time in a given queue of the current RunLoop.
382
- Calling this method with the same queue/target/method combination will have
383
- no effect (past the initial call).
384
-
385
- Note that although you can pass optional arguments these will not be
386
- considered when looking for duplicates. New arguments will replace previous
387
- calls.
388
-
389
- ```javascript
390
- import { run, scheduleOnce } from '@ember/runloop';
391
-
392
- function sayHi() {
393
- console.log('hi');
394
- }
395
-
396
- run(function() {
397
- scheduleOnce('afterRender', myContext, sayHi);
398
- scheduleOnce('afterRender', myContext, sayHi);
399
- // sayHi will only be executed once, in the afterRender queue of the RunLoop
400
- });
401
- ```
402
-
403
- Also note that for `scheduleOnce` to prevent additional calls, you need to
404
- pass the same function instance. The following case works as expected:
405
-
406
- ```javascript
407
- function log() {
408
- console.log('Logging only once');
409
- }
410
-
411
- function scheduleIt() {
412
- scheduleOnce('actions', myContext, log);
413
- }
414
-
415
- scheduleIt();
416
- scheduleIt();
417
- ```
418
-
419
- But this other case will schedule the function multiple times:
420
-
421
- ```javascript
422
- import { scheduleOnce } from '@ember/runloop';
423
-
424
- function scheduleIt() {
425
- scheduleOnce('actions', myContext, function() {
426
- console.log('Closure');
427
- });
428
- }
429
-
430
- scheduleIt();
431
- scheduleIt();
432
-
433
- // "Closure" will print twice, even though we're using `scheduleOnce`,
434
- // because the function we pass to it won't match the
435
- // previously scheduled operation.
436
- ```
437
-
438
- Available queues, and their order, can be found at `queues`
439
-
440
- @method scheduleOnce
441
- @static
442
- @for @ember/runloop
443
- @param {String} [queue] The name of the queue to schedule against. Default queues is 'actions'.
444
- @param {Object} [target] The target of the method to invoke.
445
- @param {Function|String} method The method to invoke.
446
- If you pass a string it will be resolved on the
447
- target at the time the method is invoked.
448
- @param {Object} [args*] Optional arguments to pass to the timeout.
449
- @return {Object} Timer information for use in canceling, see `cancel`.
450
- @public
451
- */
452
-
453
- export function
454
- /* queue, target, method*/
455
- scheduleOnce() {
456
- return _backburner.scheduleOnce(...arguments);
146
+ export function scheduleOnce(...args) {
147
+ // @ts-expect-error TS doesn't like the rest args here
148
+ return _backburner.scheduleOnce(...args);
457
149
  }
458
- /**
459
- Schedules an item to run from within a separate run loop, after
460
- control has been returned to the system. This is equivalent to calling
461
- `later` with a wait time of 1ms.
462
-
463
- ```javascript
464
- import { next } from '@ember/runloop';
465
-
466
- next(myContext, function() {
467
- // code to be executed in the next run loop,
468
- // which will be scheduled after the current one
469
- });
470
- ```
471
-
472
- Multiple operations scheduled with `next` will coalesce
473
- into the same later run loop, along with any other operations
474
- scheduled by `later` that expire right around the same
475
- time that `next` operations will fire.
476
-
477
- Note that there are often alternatives to using `next`.
478
- For instance, if you'd like to schedule an operation to happen
479
- after all DOM element operations have completed within the current
480
- run loop, you can make use of the `afterRender` run loop queue (added
481
- by the `ember-views` package, along with the preceding `render` queue
482
- where all the DOM element operations happen).
483
-
484
- Example:
485
-
486
- ```app/components/my-component.js
487
- import Component from '@ember/component';
488
- import { scheduleOnce } from '@ember/runloop';
489
-
490
- export Component.extend({
491
- didInsertElement() {
492
- this._super(...arguments);
493
- scheduleOnce('afterRender', this, 'processChildElements');
494
- },
495
-
496
- processChildElements() {
497
- // ... do something with component's child component
498
- // elements after they've finished rendering, which
499
- // can't be done within this component's
500
- // `didInsertElement` hook because that gets run
501
- // before the child elements have been added to the DOM.
502
- }
503
- });
504
- ```
505
-
506
- One benefit of the above approach compared to using `next` is
507
- that you will be able to perform DOM/CSS operations before unprocessed
508
- elements are rendered to the screen, which may prevent flickering or
509
- other artifacts caused by delaying processing until after rendering.
510
-
511
- The other major benefit to the above approach is that `next`
512
- introduces an element of non-determinism, which can make things much
513
- harder to test, due to its reliance on `setTimeout`; it's much harder
514
- to guarantee the order of scheduled operations when they are scheduled
515
- outside of the current run loop, i.e. with `next`.
516
-
517
- @method next
518
- @static
519
- @for @ember/runloop
520
- @param {Object} [target] target of method to invoke
521
- @param {Function|String} method The method to invoke.
522
- If you pass a string it will be resolved on the
523
- target at the time the method is invoked.
524
- @param {Object} [args*] Optional arguments to pass to the timeout.
525
- @return {Object} Timer information for use in canceling, see `cancel`.
526
- @public
527
- */
528
-
529
150
  export function next(...args) {
530
- args.push(1);
531
- return _backburner.later(...args);
151
+ return _backburner.later(...args, 1);
532
152
  }
533
153
  /**
534
154
  Cancels a scheduled item. Must be a value returned by `later()`,
@@ -601,128 +221,11 @@ export function next(...args) {
601
221
  export function cancel(timer) {
602
222
  return _backburner.cancel(timer);
603
223
  }
604
- /**
605
- Delay calling the target method until the debounce period has elapsed
606
- with no additional debounce calls. If `debounce` is called again before
607
- the specified time has elapsed, the timer is reset and the entire period
608
- must pass again before the target method is called.
609
-
610
- This method should be used when an event may be called multiple times
611
- but the action should only be called once when the event is done firing.
612
- A common example is for scroll events where you only want updates to
613
- happen once scrolling has ceased.
614
-
615
- ```javascript
616
- import { debounce } from '@ember/runloop';
617
-
618
- function whoRan() {
619
- console.log(this.name + ' ran.');
620
- }
621
-
622
- let myContext = { name: 'debounce' };
623
-
624
- debounce(myContext, whoRan, 150);
625
-
626
- // less than 150ms passes
627
- debounce(myContext, whoRan, 150);
628
-
629
- // 150ms passes
630
- // whoRan is invoked with context myContext
631
- // console logs 'debounce ran.' one time.
632
- ```
633
-
634
- Immediate allows you to run the function immediately, but debounce
635
- other calls for this function until the wait time has elapsed. If
636
- `debounce` is called again before the specified time has elapsed,
637
- the timer is reset and the entire period must pass again before
638
- the method can be called again.
639
-
640
- ```javascript
641
- import { debounce } from '@ember/runloop';
642
-
643
- function whoRan() {
644
- console.log(this.name + ' ran.');
645
- }
646
-
647
- let myContext = { name: 'debounce' };
648
-
649
- debounce(myContext, whoRan, 150, true);
650
-
651
- // console logs 'debounce ran.' one time immediately.
652
- // 100ms passes
653
- debounce(myContext, whoRan, 150, true);
654
-
655
- // 150ms passes and nothing else is logged to the console and
656
- // the debouncee is no longer being watched
657
- debounce(myContext, whoRan, 150, true);
658
-
659
- // console logs 'debounce ran.' one time immediately.
660
- // 150ms passes and nothing else is logged to the console and
661
- // the debouncee is no longer being watched
662
- ```
663
-
664
- @method debounce
665
- @static
666
- @for @ember/runloop
667
- @param {Object} [target] target of method to invoke
668
- @param {Function|String} method The method to invoke.
669
- May be a function or a string. If you pass a string
670
- then it will be looked up on the passed target.
671
- @param {Object} [args*] Optional arguments to pass to the timeout.
672
- @param {Number} wait Number of milliseconds to wait.
673
- @param {Boolean} immediate Trigger the function on the leading instead
674
- of the trailing edge of the wait interval. Defaults to false.
675
- @return {Array} Timer information for use in canceling, see `cancel`.
676
- @public
677
- */
678
-
679
- export function debounce() {
680
- return _backburner.debounce(...arguments);
224
+ export function debounce(...args) {
225
+ // @ts-expect-error TS doesn't like the rest args here
226
+ return _backburner.debounce(...args);
681
227
  }
682
- /**
683
- Ensure that the target method is never called more frequently than
684
- the specified spacing period. The target method is called immediately.
685
-
686
- ```javascript
687
- import { throttle } from '@ember/runloop';
688
-
689
- function whoRan() {
690
- console.log(this.name + ' ran.');
691
- }
692
-
693
- let myContext = { name: 'throttle' };
694
-
695
- throttle(myContext, whoRan, 150);
696
- // whoRan is invoked with context myContext
697
- // console logs 'throttle ran.'
698
-
699
- // 50ms passes
700
- throttle(myContext, whoRan, 150);
701
-
702
- // 50ms passes
703
- throttle(myContext, whoRan, 150);
704
-
705
- // 150ms passes
706
- throttle(myContext, whoRan, 150);
707
- // whoRan is invoked with context myContext
708
- // console logs 'throttle ran.'
709
- ```
710
-
711
- @method throttle
712
- @static
713
- @for @ember/runloop
714
- @param {Object} [target] target of method to invoke
715
- @param {Function|String} method The method to invoke.
716
- May be a function or a string. If you pass a string
717
- then it will be looked up on the passed target.
718
- @param {Object} [args*] Optional arguments to pass to the timeout.
719
- @param {Number} spacing Number of milliseconds to space out requests.
720
- @param {Boolean} immediate Trigger the function on the leading instead
721
- of the trailing edge of the wait interval. Defaults to true.
722
- @return {Array} Timer information for use in canceling, see `cancel`.
723
- @public
724
- */
725
-
726
- export function throttle() {
727
- return _backburner.throttle(...arguments);
228
+ export function throttle(...args) {
229
+ // @ts-expect-error TS doesn't like the rest args here
230
+ return _backburner.throttle(...args);
728
231
  }
@@ -0,0 +1,5 @@
1
+ import { begin, end } from '@ember/runloop';
2
+ import { expectTypeOf } from 'expect-type';
3
+ expectTypeOf(begin()).toEqualTypeOf(); // code to be executed within a RunLoop
4
+
5
+ expectTypeOf(end()).toEqualTypeOf();
@@ -0,0 +1,59 @@
1
+ import { bind } from '@ember/runloop';
2
+ import { expectTypeOf } from 'expect-type';
3
+
4
+ class Foo {
5
+ test(_foo, _bar, _baz) {
6
+ return 1;
7
+ }
8
+
9
+ }
10
+
11
+ let foo = new Foo(); // With only function
12
+
13
+ expectTypeOf(bind((_foo, _bar, _baz) => {
14
+ return 1;
15
+ })).toEqualTypeOf();
16
+ expectTypeOf(bind((_foo, _bar, _baz) => {
17
+ return 1;
18
+ }, 1)).toEqualTypeOf();
19
+ expectTypeOf(bind((_foo, _bar, _baz) => {
20
+ return 1;
21
+ }, 1, true)).toEqualTypeOf();
22
+ expectTypeOf(bind((_foo, _bar, _baz) => {
23
+ return 1;
24
+ }, 1, true, 'baz')).toEqualTypeOf();
25
+ expectTypeOf(bind((_foo, _bar, _baz) => {
26
+ return 1;
27
+ }, 1, true, undefined)).toEqualTypeOf();
28
+ bind(_foo => {
29
+ return 1; // @ts-expect-error invalid argument
30
+ }, 'string'); // With target and function
31
+
32
+ expectTypeOf(bind(foo, function (_foo, _bar, _baz) {
33
+ expectTypeOf(this).toEqualTypeOf();
34
+ return 1;
35
+ })).toEqualTypeOf();
36
+ expectTypeOf(bind(foo, function (_foo, _bar, _baz) {
37
+ return 1;
38
+ }, 1)).toEqualTypeOf();
39
+ expectTypeOf(bind(foo, function (_foo, _bar, _baz) {
40
+ return 1;
41
+ }, 1, true)).toEqualTypeOf();
42
+ expectTypeOf(bind(foo, function (_foo, _bar, _baz) {
43
+ return 1;
44
+ }, 1, true, 'baz')).toEqualTypeOf();
45
+ expectTypeOf(bind(foo, function (_foo, _bar, _baz) {
46
+ return 1;
47
+ }, 1, true, undefined)).toEqualTypeOf(); // @ts-expect-error Invalid args
48
+
49
+ bind(foo, function (_foo) {
50
+ return 1;
51
+ }, 'string'); // With function string reference
52
+
53
+ expectTypeOf(bind(foo, 'test')).toEqualTypeOf();
54
+ expectTypeOf(bind(foo, 'test', 1)).toEqualTypeOf();
55
+ expectTypeOf(bind(foo, 'test', 1, true)).toEqualTypeOf();
56
+ expectTypeOf(bind(foo, 'test', 1, true, 'baz')).toEqualTypeOf();
57
+ expectTypeOf(bind(foo, 'test', 1, true, undefined)).toEqualTypeOf(); // @ts-expect-error Invalid args
58
+
59
+ bind(foo, 'test', 'string');
@@ -0,0 +1,5 @@
1
+ import { cancel, next } from '@ember/runloop';
2
+ import { expectTypeOf } from 'expect-type';
3
+ let runNext = next(null, () => {// will not be executed
4
+ });
5
+ expectTypeOf(cancel(runNext)).toEqualTypeOf();