Skip to content

Commit bae5e33

Browse files
gitKrystanchriskrycho
authored andcommittedDec 15, 2022
Upgrade expect-type and fix issues the new version reveals
(cherry picked from commit 3f42108)
1 parent d537923 commit bae5e33

File tree

8 files changed

+36
-42
lines changed

8 files changed

+36
-42
lines changed
 

‎API.md

+20-22
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Emulating filling an input with text using `fillIn`
223223
fillIn('input', 'hello world');
224224
```
225225

226-
Returns **[Promise][66]<([Element][65] | void)>** resolves when the application is settled
226+
Returns **[Promise][66]\<void>** resolves when the application is settled
227227

228228
### focus
229229

@@ -376,7 +376,7 @@ Emulating tapping a button using `tap`
376376
tap('button');
377377
```
378378

379-
Returns **[Promise][66]<([Event][73] | [Array][70]<[Event][73]> | void)>** resolves when settled
379+
Returns **[Promise][66]\<void>** resolves when settled
380380

381381
### triggerEvent
382382

@@ -394,7 +394,7 @@ Using `triggerEvent` to upload a file
394394

395395
When using `triggerEvent` to upload a file the `eventType` must be `change` and you must pass the
396396
`options` param as an object with a key `files` containing an array of
397-
[Blob][74].
397+
[Blob][73].
398398

399399
```javascript
400400
triggerEvent(
@@ -406,8 +406,8 @@ triggerEvent(
406406

407407
Using `triggerEvent` to upload a dropped file
408408

409-
When using `triggerEvent` to handle a dropped (via drag-and-drop) file, the `eventType` must be `drop`. Assuming your `drop` event handler uses the [DataTransfer API][75],
410-
you must pass the `options` param as an object with a key of `dataTransfer`. The `options.dataTransfer` object should have a `files` key, containing an array of [File][76].
409+
When using `triggerEvent` to handle a dropped (via drag-and-drop) file, the `eventType` must be `drop`. Assuming your `drop` event handler uses the [DataTransfer API][74],
410+
you must pass the `options` param as an object with a key of `dataTransfer`. The `options.dataTransfer` object should have a `files` key, containing an array of [File][75].
411411

412412
```javascript
413413
triggerEvent(
@@ -426,8 +426,8 @@ Returns **[Promise][66]\<void>** resolves when the application is settled
426426
### triggerKeyEvent
427427

428428
Triggers a keyboard event of given type in the target element.
429-
It also requires the developer to provide either a string with the [`key`][77]
430-
or the numeric [`keyCode`][78] of the pressed key.
429+
It also requires the developer to provide either a string with the [`key`][76]
430+
or the numeric [`keyCode`][77] of the pressed key.
431431
Optionally the user can also provide a POJO with extra modifiers for the event.
432432

433433
#### Parameters
@@ -596,7 +596,7 @@ while *not* settled (e.g. "loading" or "pending" states).
596596

597597
#### Parameters
598598

599-
* `callback` **[Function][79]** the callback to use for testing when waiting should stop
599+
* `callback` **[Function][78]** the callback to use for testing when waiting should stop
600600
* `options` **[Object][72]?** options used to override defaults (optional, default `{}`)
601601

602602
* `options.timeout` **[number][69]** the maximum amount of time to wait (optional, default `1000`)
@@ -856,9 +856,9 @@ element).
856856

857857
#### Parameters
858858

859-
* `context` **[Object][72]** the context to setup for rendering
859+
* `context` **TestContext** the context to setup for rendering
860860

861-
Returns **[Promise][66]<[Object][72]>** resolves with the context that was setup
861+
Returns **[Promise][66]\<RenderingTestContext>** resolves with the context that was setup
862862

863863
### getApplication
864864

@@ -906,7 +906,7 @@ everything is on fire...
906906

907907
#### Parameters
908908

909-
* `callback` **[Function][79]** the callback to validate (optional, default `Ember.onerror`)
909+
* `callback` **[Function][78]** the callback to validate (optional, default `Ember.onerror`)
910910

911911
#### Examples
912912

@@ -931,7 +931,7 @@ without an `onError` argument.
931931

932932
#### Parameters
933933

934-
* `onError` **[Function][79]** the onError function to be set on Ember.onerror
934+
* `onError` **[Function][78]** the onError function to be set on Ember.onerror
935935

936936
#### Examples
937937

@@ -1018,7 +1018,7 @@ Returns deprecations which have occured so far for a the current test context
10181018

10191019
### Parameters
10201020

1021-
* `callback` **[Function][79]?** The callback that when executed will have its DeprecationFailure recorded
1021+
* `callback` **[Function][78]?** The callback that when executed will have its DeprecationFailure recorded
10221022

10231023
### Examples
10241024

@@ -1076,7 +1076,7 @@ Returns warnings which have occured so far for a the current test context
10761076

10771077
### Parameters
10781078

1079-
* `callback` **[Function][79]?** The callback that when executed will have its warnings recorded
1079+
* `callback` **[Function][78]?** The callback that when executed will have its warnings recorded
10801080

10811081
### Examples
10821082

@@ -1252,16 +1252,14 @@ Returns **([Array][70]\<Warning> | [Promise][66]<[Array][70]\<Warning>>)** An ar
12521252

12531253
[72]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
12541254

1255-
[73]: https://developer.mozilla.org/docs/Web/API/Event
1256-
1257-
[74]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
1255+
[73]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
12581256

1259-
[75]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
1257+
[74]: https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
12601258

1261-
[76]: https://developer.mozilla.org/en-US/docs/Web/API/File
1259+
[75]: https://developer.mozilla.org/en-US/docs/Web/API/File
12621260

1263-
[77]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
1261+
[76]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
12641262

1265-
[78]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
1263+
[77]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
12661264

1267-
[79]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1265+
[78]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

‎addon-test-support/@ember/test-helpers/dom/fill-in.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ registerHook('fillIn', 'start', (target: Target, text: string) => {
2121
@public
2222
@param {string|Element} target the element or selector to enter text into
2323
@param {string} text the text to fill into the target element
24-
@return {Promise<Element | void>} resolves when the application is settled
24+
@return {Promise<void>} resolves when the application is settled
2525
2626
@example
2727
<caption>
@@ -30,10 +30,7 @@ registerHook('fillIn', 'start', (target: Target, text: string) => {
3030
3131
fillIn('input', 'hello world');
3232
*/
33-
export default function fillIn(
34-
target: Target,
35-
text: string
36-
): Promise<Element | void> {
33+
export default function fillIn(target: Target, text: string): Promise<void> {
3734
return Promise.resolve()
3835
.then(() => runHooks('fillIn', 'start', target, text))
3936
.then(() => {

‎addon-test-support/@ember/test-helpers/dom/tap.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ registerHook('tap', 'start', (target: Target) => {
4545
@public
4646
@param {string|Element} target the element or selector to tap on
4747
@param {Object} options the options to be merged into the touch events
48-
@return {Promise<Event | Event[] | void>} resolves when settled
48+
@return {Promise<void>} resolves when settled
4949
5050
@example
5151
<caption>
@@ -57,7 +57,7 @@ registerHook('tap', 'start', (target: Target) => {
5757
export default function tap(
5858
target: Target,
5959
options: TouchEventInit = {}
60-
): Promise<Event | Event[] | void> {
60+
): Promise<void> {
6161
return Promise.resolve()
6262
.then(() => {
6363
return runHooks('tap', 'start', target, options);

‎addon-test-support/@ember/test-helpers/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export {
3030
render,
3131
clearRender,
3232
} from './setup-rendering-context';
33+
export type { RenderingTestContext } from './setup-rendering-context';
3334
export { default as rerender } from './rerender';
3435
export {
3536
default as setupApplicationContext,

‎addon-test-support/@ember/test-helpers/setup-rendering-context.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import settled from './settled';
1313
import { hbs, TemplateFactory } from 'ember-cli-htmlbars';
1414
import getRootElement from './dom/get-root-element';
1515
import { Owner } from './build-owner';
16-
import getTestMetadata, { TestMetadata } from './test-metadata';
16+
import getTestMetadata from './test-metadata';
1717
import { assert, deprecate } from '@ember/debug';
1818
import { runHooks } from './-internal/helper-hooks';
1919
import hasEmberVersion from './has-ember-version';
@@ -22,7 +22,6 @@ import { macroCondition, dependencySatisfies } from '@embroider/macros';
2222
import { ComponentRenderMap, SetUsage } from './setup-context';
2323
import { ensureSafeComponent } from '@embroider/util';
2424
import type { ComponentInstance } from '@glimmer/interfaces';
25-
import ViewMixin from '@ember/component/-private/view-mixin';
2625

2726
const OUTLET_TEMPLATE = hbs`{{outlet}}`;
2827
const EMPTY_TEMPLATE = hbs``;
@@ -32,8 +31,6 @@ export interface RenderingTestContext extends TestContext {
3231
render(template: TemplateFactory): Promise<void>;
3332
clearRender(): Promise<void>;
3433

35-
$?(selector: string): any;
36-
3734
element: Element | Document;
3835
}
3936

@@ -271,8 +268,8 @@ export function clearRender(): Promise<void> {
271268
element).
272269
273270
@public
274-
@param {Object} context the context to setup for rendering
275-
@returns {Promise<Object>} resolves with the context that was setup
271+
@param {TestContext} context the context to setup for rendering
272+
@returns {Promise<RenderingTestContext>} resolves with the context that was setup
276273
*/
277274
export default function setupRenderingContext(
278275
context: TestContext

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"eslint-plugin-disable-features": "^0.1.3",
100100
"eslint-plugin-node": "^11.1.0",
101101
"eslint-plugin-prettier": "^4.0.0",
102-
"expect-type": "^0.13.0",
102+
"expect-type": "^0.15.0",
103103
"fs-extra": "^10.0.0",
104104
"latest-version": "^5.0.0",
105105
"loader.js": "^4.7.0",

‎type-tests/api.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
focus,
1010
scrollTo,
1111
select,
12+
tab,
1213
tap,
1314
triggerEvent,
1415
triggerKeyEvent,
@@ -45,6 +46,7 @@ import {
4546
unsetContext,
4647
teardownContext,
4748
setupRenderingContext,
49+
RenderingTestContext,
4850
getApplication,
4951
setApplication,
5052
setupApplicationContext,
@@ -63,7 +65,6 @@ import {
6365
DebugInfo as InternalDebugInfo,
6466
DeprecationFailure,
6567
Warning,
66-
tab,
6768
} from '@ember/test-helpers';
6869
import { ComponentInstance } from '@glimmer/interfaces';
6970
import { Owner } from '@ember/test-helpers/build-owner';
@@ -219,7 +220,7 @@ expectTypeOf(teardownContext).toEqualTypeOf<
219220
) => Promise<void>
220221
>();
221222
expectTypeOf(setupRenderingContext).toEqualTypeOf<
222-
(context: TestContext) => Promise<void>
223+
(context: TestContext) => Promise<RenderingTestContext>
223224
>();
224225
expectTypeOf(getApplication).toEqualTypeOf<() => Application | undefined>();
225226
expectTypeOf(setApplication).toEqualTypeOf<

‎yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -6470,10 +6470,10 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
64706470
dependencies:
64716471
homedir-polyfill "^1.0.1"
64726472

6473-
expect-type@^0.13.0:
6474-
version "0.13.0"
6475-
resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-0.13.0.tgz#916646a7a73f3ee77039a634ee9035efe1876eb2"
6476-
integrity sha512-CclevazQfrqo8EvbLPmP7osnb1SZXkw47XPPvUUpeMz4HuGzDltE7CaIt3RLyT9UQrwVK/LDn+KVcC0hcgjgDg==
6473+
expect-type@^0.15.0:
6474+
version "0.15.0"
6475+
resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-0.15.0.tgz#89f75e22c88554844ea2b2faf4ef5fc2e579d3b5"
6476+
integrity sha512-yWnriYB4e8G54M5/fAFj7rCIBiKs1HAACaY13kCz6Ku0dezjS9aMcfcdVK2X8Tv2tEV1BPz/wKfQ7WA4S/d8aA==
64776477

64786478
express@^4.10.7, express@^4.17.1:
64796479
version "4.18.2"

0 commit comments

Comments
 (0)
Please sign in to comment.