Skip to content

Commit

Permalink
Merge pull request #1467 from emberjs/fix-type-imports
Browse files Browse the repository at this point in the history
Fix import type via upgrading @tsconfig/ember
  • Loading branch information
NullVoxPopuli authored Jul 24, 2024
2 parents 44be785 + 63b1d5d commit e77fc12
Show file tree
Hide file tree
Showing 42 changed files with 192 additions and 105 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ jobs:
cache: pnpm
- name: Install Dependencies
run: pnpm install
- name: Build addon
working-directory: addon
run: pnpm build
- run: pnpm test
- name: own types
working-directory: addon
run: pnpm tsc --noEmit

floating:
name: "Floating Dependencies"
Expand All @@ -52,8 +58,14 @@ jobs:
cache: pnpm
- name: Install Dependencies
run: pnpm install --no-lockfile
- name: Build addon
working-directory: addon
run: pnpm build
- name: Run Tests
run: pnpm test
- name: own types
working-directory: addon
run: pnpm tsc --noEmit

try-scenarios:
timeout-minutes: 10
Expand Down Expand Up @@ -88,6 +100,9 @@ jobs:
cache: pnpm
- name: Install Dependencies
run: pnpm install
- name: Build addon
working-directory: addon
run: pnpm build
- name: test
working-directory: addon
run: node_modules/.bin/ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup
Expand Down Expand Up @@ -121,9 +136,12 @@ jobs:
cache: pnpm
- name: Install Dependencies
run: pnpm install
- name: install TS version
- name: Build types for addon
working-directory: addon
run: pnpm build
- name: install TS version
working-directory: type-tests
run: pnpm add --save-dev typescript@${{matrix.ts-version}}
- name: test types
working-directory: addon
run: pnpm lint:ts
- name: public types
working-directory: type-tests
run: pnpm test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import EmberObject from '@ember/object';
import require, { has } from 'require';
import Ember from 'ember';

import { FullName } from '@ember/owner';
import type { FullName } from '@ember/owner';

// These shenanigans work around the fact that the import locations are not
// public API and are not stable, so we jump through hoops to get the right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// "provides" this public API, but does not for earlier versions. As a result,
// this type will be `any`.
import { _backburner } from '@ember/runloop';
import { DebugInfo as BackburnerDebugInfo } from '@ember/runloop/-private/backburner';
import { DebugInfoHelper, debugInfoHelpers } from './debug-info-helpers';
import { getPendingWaiterState, PendingWaiterState } from '@ember/test-waiters';
import type { DebugInfo as BackburnerDebugInfo } from '@ember/runloop/-private/backburner';
import { type DebugInfoHelper, debugInfoHelpers } from './debug-info-helpers';
import {
getPendingWaiterState,
type PendingWaiterState,
} from '@ember/test-waiters';

const PENDING_AJAX_REQUESTS = 'Pending AJAX requests';
const PENDING_TEST_WAITERS = 'Pending test waiters';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseContext } from '../setup-context';
import type { BaseContext } from '../setup-context';
import { registerDeprecationHandler } from '@ember/debug';
import isPromise from './is-promise';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseContext } from '../setup-context';
import type { BaseContext } from '../setup-context';
import { registerWarnHandler } from '@ember/debug';
import isPromise from './is-promise';

Expand Down
4 changes: 2 additions & 2 deletions addon/addon-test-support/@ember/test-helpers/build-owner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Application from '@ember/application';
import type { Resolver } from '@ember/owner';

import legacyBuildRegistry from './-internal/build-registry';
import EmberOwner from '@ember/owner';
import { SimpleElement } from '@simple-dom/interface';
import type EmberOwner from '@ember/owner';
import type { SimpleElement } from '@simple-dom/interface';

export interface Owner extends EmberOwner {
_emberTestHelpersMockOwner?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isDescriptor, lookupDescriptorData } from 'dom-element-descriptors';
import type Target from './-target';
import type { Target } from './-target';

/**
Used internally by the DOM interaction helpers to get a description of a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getRootElement from './get-root-element';
import Target, { isDocument, isElement } from './-target';
import { type Target, isDocument, isElement } from './-target';
import {
type IDOMElementDescriptor,
lookupDescriptorData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getElement from './-get-element';
import Target, { isWindow } from './-target';
import { type Target, isWindow } from './-target';

/**
Used internally by the DOM interaction helpers to find either window or an element.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormControl } from './-is-form-control';
import type { FormControl } from './-is-form-control';

// ref: https://html.spec.whatwg.org/multipage/input.html#concept-input-apply
const constrainedInputTypes = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Target from './-target';
import type { Target } from './-target';

/**
* Logs a debug message to the console if the `testHelperLogging` query
Expand Down
9 changes: 6 additions & 3 deletions addon/addon-test-support/@ember/test-helpers/dom/-target.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { IDOMElementDescriptor } from 'dom-element-descriptors';

type Target = string | Element | IDOMElementDescriptor | Document | Window;

export default Target;
export type Target =
| string
| Element
| IDOMElementDescriptor
| Document
| Window;

export interface HTMLElementContentEditable extends HTMLElement {
isContentEditable: true;
Expand Down
2 changes: 1 addition & 1 deletion addon/addon-test-support/@ember/test-helpers/dom/blur.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import getElement from './-get-element';
import fireEvent from './fire-event';
import settled from '../settled';
import Target from './-target';
import type { Target } from './-target';
import { log } from './-logging';
import isFocusable from './-is-focusable';
import { runHooks, registerHook } from '../helper-hooks';
Expand Down
2 changes: 1 addition & 1 deletion addon/addon-test-support/@ember/test-helpers/dom/click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fireEvent from './fire-event';
import { __focus__ } from './focus';
import settled from '../settled';
import isFormControl from './-is-form-control';
import Target, { isWindow } from './-target';
import { isWindow, type Target } from './-target';
import { log } from './-logging';
import { runHooks, registerHook } from '../helper-hooks';
import getDescription from './-get-description';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fireEvent from './fire-event';
import { __focus__ } from './focus';
import settled from '../settled';
import { DEFAULT_CLICK_OPTIONS } from './click';
import Target, { isWindow } from './-target';
import { isWindow, type Target } from './-target';
import { log } from './-logging';
import isFormControl from './-is-form-control';
import { runHooks, registerHook } from '../helper-hooks';
Expand Down
4 changes: 2 additions & 2 deletions addon/addon-test-support/@ember/test-helpers/dom/fill-in.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import getElement from './-get-element';
import isFormControl, { FormControl } from './-is-form-control';
import isFormControl, { type FormControl } from './-is-form-control';
import guardForMaxlength from './-guard-for-maxlength';
import { __focus__ } from './focus';
import settled from '../settled';
import fireEvent from './fire-event';
import Target, { isContentEditable } from './-target';
import { isContentEditable, type Target } from './-target';
import { log } from './-logging';
import { runHooks, registerHook } from '../helper-hooks';
import getDescription from './-get-description';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isDocument, isElement } from './-target';
import tuple from '../-tuple';
import Target from './-target';
import type { Target } from './-target';
import { log } from './-logging';
import { runHooks, registerHook } from '../helper-hooks';

Expand Down
2 changes: 1 addition & 1 deletion addon/addon-test-support/@ember/test-helpers/dom/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import getElement from './-get-element';
import fireEvent from './fire-event';
import settled from '../settled';
import isFocusable from './-is-focusable';
import Target, { isDocument } from './-target';
import { isDocument, type Target } from './-target';
import { log } from './-logging';
import { runHooks, registerHook } from '../helper-hooks';
import { __blur__ } from './blur';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import getElement from './-get-element';
import fireEvent from './fire-event';
import settled from '../settled';
import Target, { isDocument, isElement } from './-target';
import type { Target } from './-target';
import { isDocument, isElement } from './-target';
import { runHooks } from '../helper-hooks';
import type { IDOMElementDescriptor } from 'dom-element-descriptors';
import getDescription from './-get-description';
Expand Down
2 changes: 1 addition & 1 deletion addon/addon-test-support/@ember/test-helpers/dom/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import isSelectElement from './-is-select-element';
import { __focus__ } from './focus';
import settled from '../settled';
import fireEvent from './fire-event';
import Target from './-target';
import type { Target } from './-target';
import { runHooks } from '../helper-hooks';
import getDescription from './-get-description';

Expand Down
3 changes: 2 additions & 1 deletion addon/addon-test-support/@ember/test-helpers/dom/tab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import getRootElement from './get-root-element';
import settled from '../settled';
import fireEvent, { _buildKeyboardEvent } from './fire-event';
import Target, { isDocument } from './-target';
import type { Target } from './-target';
import { isDocument } from './-target';
import { __blur__ } from './blur';
import { __focus__ } from './focus';
import { isVisible, isDisabled } from '../-utils';
Expand Down
2 changes: 1 addition & 1 deletion addon/addon-test-support/@ember/test-helpers/dom/tap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import getElement from './-get-element';
import fireEvent from './fire-event';
import { __click__ } from './click';
import settled from '../settled';
import Target from './-target';
import type { Target } from './-target';
import { log } from './-logging';
import isFormControl from './-is-form-control';
import { runHooks, registerHook } from '../helper-hooks';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getWindowOrElement } from './-get-window-or-element';
import fireEvent from './fire-event';
import settled from '../settled';
import Target from './-target';
import type { Target } from './-target';
import { log } from './-logging';
import isFormControl from './-is-form-control';
import { runHooks, registerHook } from '../helper-hooks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import fireEvent from './fire-event';
import settled from '../settled';
import {
KEYBOARD_EVENT_TYPES,
KeyboardEventType,
type KeyboardEventType,
isKeyboardEventType,
} from './fire-event';
import { isNumeric } from '../-utils';
import Target from './-target';
import type { Target } from './-target';
import { log } from './-logging';
import isFormControl from './-is-form-control';
import { runHooks, registerHook } from '../helper-hooks';
Expand Down
7 changes: 4 additions & 3 deletions addon/addon-test-support/@ember/test-helpers/dom/type-in.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import settled from '../settled';
import getElement from './-get-element';
import isFormControl, { FormControl } from './-is-form-control';
import isFormControl, { type FormControl } from './-is-form-control';
import { __focus__ } from './focus';
import fireEvent from './fire-event';
import guardForMaxlength from './-guard-for-maxlength';
import Target, {
import {
type Target,
isContentEditable,
isDocument,
HTMLElementContentEditable,
type HTMLElementContentEditable,
} from './-target';
import { __triggerKeyEvent__ } from './trigger-key-event';
import { log } from './-logging';
Expand Down
4 changes: 2 additions & 2 deletions addon/addon-test-support/@ember/test-helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Backburner,
DeferredActionQueues,
} from '@ember/runloop/-private/backburner';
Expand Down Expand Up @@ -74,7 +74,7 @@ export { default as find } from './dom/find';
export { default as findAll } from './dom/find-all';
export { default as typeIn } from './dom/type-in';
export { default as scrollTo } from './dom/scroll-to';
export type { default as Target } from './dom/-target';
export type { Target } from './dom/-target';

// Declaration-merge for our internal purposes.
declare module '@ember/runloop' {
Expand Down
48 changes: 32 additions & 16 deletions addon/addon-test-support/@ember/test-helpers/settled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { nextTick } from './-utils';
import waitUntil from './wait-until';
import { hasPendingTransitions } from './setup-application-context';
import { hasPendingWaiters } from '@ember/test-waiters';
import DebugInfo, { TestDebugInfo } from './-internal/debug-info';
import type DebugInfo from './-internal/debug-info';
import { TestDebugInfo } from './-internal/debug-info';

// Ember internally tracks AJAX requests in the same way that we do here for
// legacy style "acceptance" tests using the `ember-testing.js` asset provided
Expand Down Expand Up @@ -42,7 +43,10 @@ const _internalGetPendingRequestsCount = () => {
return 0;
};

if (typeof jQuery !== 'undefined' && _internalPendingRequestsModule) {
if (
typeof (globalThis as any).jQuery !== 'undefined' &&
_internalPendingRequestsModule
) {
// This exists to ensure that the AJAX listeners setup by Ember itself
// (which as of 2.17 are not properly torn down) get cleared and released
// when the application is destroyed. Without this, any AJAX requests
Expand All @@ -52,14 +56,18 @@ if (typeof jQuery !== 'undefined' && _internalPendingRequestsModule) {
// This can be removed once Ember 4.0.0 is released
EmberApplicationInstance.reopen({
willDestroy(this: EmberApplicationInstance, ...args: any[]) {
jQuery(document).off(
'ajaxSend',
_internalPendingRequestsModule.incrementPendingRequests
);
jQuery(document).off(
'ajaxComplete',
_internalPendingRequestsModule.decrementPendingRequests
);
(globalThis as any)
.jQuery(document)
.off(
'ajaxSend',
_internalPendingRequestsModule.incrementPendingRequests
);
(globalThis as any)
.jQuery(document)
.off(
'ajaxComplete',
_internalPendingRequestsModule.decrementPendingRequests
);

_internalPendingRequestsModule.clearPendingRequests();

Expand Down Expand Up @@ -128,12 +136,16 @@ export function _teardownAJAXHooks() {
// We can no longer handle any remaining requests
requests = [];

if (typeof jQuery === 'undefined') {
if (typeof (globalThis as any).jQuery === 'undefined') {
return;
}

jQuery(document).off('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).off('ajaxComplete', decrementAjaxPendingRequests);
(globalThis as any)
.jQuery(document)
.off('ajaxSend', incrementAjaxPendingRequests);
(globalThis as any)
.jQuery(document)
.off('ajaxComplete', decrementAjaxPendingRequests);
}

/**
Expand All @@ -144,12 +156,16 @@ export function _teardownAJAXHooks() {
export function _setupAJAXHooks() {
requests = [];

if (typeof jQuery === 'undefined') {
if (typeof (globalThis as any).jQuery === 'undefined') {
return;
}

jQuery(document).on('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests);
(globalThis as any)
.jQuery(document)
.on('ajaxSend', incrementAjaxPendingRequests);
(globalThis as any)
.jQuery(document)
.on('ajaxComplete', decrementAjaxPendingRequests);
}

let _internalCheckWaiters: Function;
Expand Down
Loading

0 comments on commit e77fc12

Please sign in to comment.