From 90f78e7a5612bbe6eda0f71a5133916146631fa8 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Wed, 19 Apr 2023 08:30:04 -0600 Subject: [PATCH 001/104] Publish types from source and remove preview types Remove *all* preview types, update the publishing script to publish all packages from source, and update the publishing tsconfig to include all source packages. **This *does not work* yet.** However, it is a necessary first step in the process of switching to publishing stable types: the remaining types are too deeply entangled with each other to publish them in chunks as we have to date. (If there are exceptions, I have not found them, and the overhead of finding them is higher than the cost of just doing this switch-over.) --- tsconfig/publish-types.json | 9 +- .../-private/event-dispatcher.d.ts | 18 - .../@ember/application/-private/registry.d.ts | 15 - types/preview/@ember/application/index.d.ts | 136 ----- .../preview/@ember/application/instance.d.ts | 9 - types/preview/@ember/application/types.d.ts | 29 - .../@ember/array/-private/enumerable.d.ts | 13 - .../array/-private/mutable-enumerable.d.ts | 13 - .../@ember/array/-private/native-array.d.ts | 181 ------ types/preview/@ember/array/index.d.ts | 251 --------- types/preview/@ember/array/mutable.d.ts | 94 ---- types/preview/@ember/array/proxy.d.ts | 29 - .../-private/class-names-support.d.ts | 27 - .../@ember/component/-private/core-view.d.ts | 14 - .../-private/glimmer-interfaces.d.ts | 49 -- .../component/-private/signature-utils.d.ts | 107 ---- .../@ember/component/-private/view-mixin.d.ts | 59 -- types/preview/@ember/component/helper.d.ts | 122 ---- types/preview/@ember/component/index.d.ts | 164 ------ .../@ember/component/template-only.d.ts | 47 -- types/preview/@ember/controller/index.d.ts | 47 -- .../@ember/debug/container-debug-adapter.d.ts | 14 - types/preview/@ember/debug/data-adapter.d.ts | 64 --- types/preview/@ember/debug/index.d.ts | 98 ---- types/preview/@ember/destroyable/index.d.ts | 23 - .../-private/container-proxy-mixin.d.ts | 11 - .../engine/-private/registry-proxy-mixin.d.ts | 12 - .../engine/-private/types/initializer.d.ts | 8 - types/preview/@ember/engine/index.d.ts | 45 -- types/preview/@ember/engine/instance.d.ts | 25 - types/preview/@ember/helper/index.d.ts | 49 -- types/preview/@ember/modifier/index.d.ts | 33 -- .../object/-private/action-handler.d.ts | 31 - .../preview/@ember/object/-private/types.d.ts | 63 --- types/preview/@ember/object/compat.d.ts | 9 - types/preview/@ember/object/computed.d.ts | 263 --------- types/preview/@ember/object/core.d.ts | 89 --- types/preview/@ember/object/evented.d.ts | 45 -- types/preview/@ember/object/events.d.ts | 47 -- types/preview/@ember/object/index.d.ts | 126 ----- types/preview/@ember/object/internals.d.ts | 17 - types/preview/@ember/object/mixin.d.ts | 19 - types/preview/@ember/object/observable.d.ts | 89 --- types/preview/@ember/object/observers.d.ts | 34 -- .../@ember/object/promise-proxy-mixin.d.ts | 37 -- types/preview/@ember/object/proxy.d.ts | 27 - .../@ember/routing/-private/router-dsl.d.ts | 20 - .../preview/@ember/routing/hash-location.d.ts | 26 - .../@ember/routing/history-location.d.ts | 25 - types/preview/@ember/routing/index.d.ts | 17 - types/preview/@ember/routing/location.d.ts | 104 ---- .../preview/@ember/routing/none-location.d.ts | 27 - types/preview/@ember/routing/route-info.d.ts | 73 --- types/preview/@ember/routing/route.d.ts | 532 ------------------ .../@ember/routing/router-service.d.ts | 359 ------------ types/preview/@ember/routing/router.d.ts | 41 -- types/preview/@ember/routing/transition.d.ts | 126 ----- types/preview/@ember/routing/types.d.ts | 15 - .../@ember/runloop/-private/backburner.d.ts | 43 -- .../@ember/runloop/-private/types.d.ts | 9 - types/preview/@ember/runloop/index.d.ts | 175 ------ types/preview/@ember/runloop/types.d.ts | 5 - types/preview/@ember/service/index.d.ts | 32 -- .../@ember/template-compilation/index.d.ts | 28 - .../@ember/template/-private/handlebars.d.ts | 7 - types/preview/@ember/template/index.d.ts | 6 - types/preview/@ember/test/adapter.d.ts | 22 - types/preview/@ember/test/index.d.ts | 49 -- .../preview/@ember/utils/-private/types.d.ts | 39 -- types/preview/@ember/utils/index.d.ts | 42 -- types/preview/ember/-private/type-utils.d.ts | 57 -- types/preview/ember/index.d.ts | 347 ------------ types/preview/index.d.ts | 121 ---- types/publish.mjs | 328 +---------- 74 files changed, 7 insertions(+), 5379 deletions(-) delete mode 100644 types/preview/@ember/application/-private/event-dispatcher.d.ts delete mode 100644 types/preview/@ember/application/-private/registry.d.ts delete mode 100644 types/preview/@ember/application/index.d.ts delete mode 100644 types/preview/@ember/application/instance.d.ts delete mode 100644 types/preview/@ember/application/types.d.ts delete mode 100644 types/preview/@ember/array/-private/enumerable.d.ts delete mode 100644 types/preview/@ember/array/-private/mutable-enumerable.d.ts delete mode 100644 types/preview/@ember/array/-private/native-array.d.ts delete mode 100644 types/preview/@ember/array/index.d.ts delete mode 100644 types/preview/@ember/array/mutable.d.ts delete mode 100644 types/preview/@ember/array/proxy.d.ts delete mode 100644 types/preview/@ember/component/-private/class-names-support.d.ts delete mode 100644 types/preview/@ember/component/-private/core-view.d.ts delete mode 100644 types/preview/@ember/component/-private/glimmer-interfaces.d.ts delete mode 100644 types/preview/@ember/component/-private/signature-utils.d.ts delete mode 100644 types/preview/@ember/component/-private/view-mixin.d.ts delete mode 100644 types/preview/@ember/component/helper.d.ts delete mode 100644 types/preview/@ember/component/index.d.ts delete mode 100644 types/preview/@ember/component/template-only.d.ts delete mode 100644 types/preview/@ember/controller/index.d.ts delete mode 100644 types/preview/@ember/debug/container-debug-adapter.d.ts delete mode 100644 types/preview/@ember/debug/data-adapter.d.ts delete mode 100644 types/preview/@ember/debug/index.d.ts delete mode 100644 types/preview/@ember/destroyable/index.d.ts delete mode 100644 types/preview/@ember/engine/-private/container-proxy-mixin.d.ts delete mode 100644 types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts delete mode 100644 types/preview/@ember/engine/-private/types/initializer.d.ts delete mode 100644 types/preview/@ember/engine/index.d.ts delete mode 100644 types/preview/@ember/engine/instance.d.ts delete mode 100644 types/preview/@ember/helper/index.d.ts delete mode 100644 types/preview/@ember/modifier/index.d.ts delete mode 100644 types/preview/@ember/object/-private/action-handler.d.ts delete mode 100644 types/preview/@ember/object/-private/types.d.ts delete mode 100644 types/preview/@ember/object/compat.d.ts delete mode 100644 types/preview/@ember/object/computed.d.ts delete mode 100644 types/preview/@ember/object/core.d.ts delete mode 100644 types/preview/@ember/object/evented.d.ts delete mode 100644 types/preview/@ember/object/events.d.ts delete mode 100644 types/preview/@ember/object/index.d.ts delete mode 100644 types/preview/@ember/object/internals.d.ts delete mode 100644 types/preview/@ember/object/mixin.d.ts delete mode 100644 types/preview/@ember/object/observable.d.ts delete mode 100644 types/preview/@ember/object/observers.d.ts delete mode 100644 types/preview/@ember/object/promise-proxy-mixin.d.ts delete mode 100644 types/preview/@ember/object/proxy.d.ts delete mode 100644 types/preview/@ember/routing/-private/router-dsl.d.ts delete mode 100644 types/preview/@ember/routing/hash-location.d.ts delete mode 100644 types/preview/@ember/routing/history-location.d.ts delete mode 100644 types/preview/@ember/routing/index.d.ts delete mode 100644 types/preview/@ember/routing/location.d.ts delete mode 100644 types/preview/@ember/routing/none-location.d.ts delete mode 100644 types/preview/@ember/routing/route-info.d.ts delete mode 100644 types/preview/@ember/routing/route.d.ts delete mode 100644 types/preview/@ember/routing/router-service.d.ts delete mode 100644 types/preview/@ember/routing/router.d.ts delete mode 100644 types/preview/@ember/routing/transition.d.ts delete mode 100644 types/preview/@ember/routing/types.d.ts delete mode 100644 types/preview/@ember/runloop/-private/backburner.d.ts delete mode 100644 types/preview/@ember/runloop/-private/types.d.ts delete mode 100644 types/preview/@ember/runloop/index.d.ts delete mode 100644 types/preview/@ember/runloop/types.d.ts delete mode 100644 types/preview/@ember/service/index.d.ts delete mode 100644 types/preview/@ember/template-compilation/index.d.ts delete mode 100644 types/preview/@ember/template/-private/handlebars.d.ts delete mode 100644 types/preview/@ember/template/index.d.ts delete mode 100644 types/preview/@ember/test/adapter.d.ts delete mode 100644 types/preview/@ember/test/index.d.ts delete mode 100644 types/preview/@ember/utils/-private/types.d.ts delete mode 100644 types/preview/@ember/utils/index.d.ts delete mode 100644 types/preview/ember/-private/type-utils.d.ts delete mode 100755 types/preview/ember/index.d.ts delete mode 100644 types/preview/index.d.ts diff --git a/tsconfig/publish-types.json b/tsconfig/publish-types.json index 3e459bb6039..b0f8a517e0d 100644 --- a/tsconfig/publish-types.json +++ b/tsconfig/publish-types.json @@ -16,16 +16,11 @@ "declarationDir": "../types/stable" }, "include": [ - // Note: these will also pull on all their transitive dependencies, so we - // will end up publishing the (private!) types for packages not named here - // until we update the actual internals to avoid referencing them! - "../packages/@ember/**/*", - "../packages/ember/**/*", - "../packages/@glimmer/**/*" + "../packages/**/*.ts" ], "exclude": [ "../**/type-tests", "../**/tests", "../**/internal-test-helpers" ] -} +} \ No newline at end of file diff --git a/types/preview/@ember/application/-private/event-dispatcher.d.ts b/types/preview/@ember/application/-private/event-dispatcher.d.ts deleted file mode 100644 index f88ebe85a7c..00000000000 --- a/types/preview/@ember/application/-private/event-dispatcher.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare module '@ember/application/-private/event-dispatcher' { - import { EventDispatcherEvents } from '@ember/application/types'; - - /** - * `Ember.EventDispatcher` handles delegating browser events to their - * corresponding `Ember.Views.` For example, when you click on a view, - * `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets - * called. - */ - export default class EventDispatcher extends Object { - /** - * The set of events names (and associated handler function names) to be setup - * and dispatched by the `EventDispatcher`. Modifications to this list can be done - * at setup time, generally via the `Ember.Application.customEvents` hash. - */ - events: EventDispatcherEvents; - } -} diff --git a/types/preview/@ember/application/-private/registry.d.ts b/types/preview/@ember/application/-private/registry.d.ts deleted file mode 100644 index 1af8dff3ef8..00000000000 --- a/types/preview/@ember/application/-private/registry.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare module '@ember/application/-private/registry' { - import { EmberClassConstructor } from '@ember/object/-private/types'; - - /** - * A registry used to store factory and option information keyed - * by type. - */ - export default class Registry { - register( - fullName: string, - factory: EmberClassConstructor, - options?: { singleton?: boolean | undefined } - ): void; - } -} diff --git a/types/preview/@ember/application/index.d.ts b/types/preview/@ember/application/index.d.ts deleted file mode 100644 index 1f83001eafc..00000000000 --- a/types/preview/@ember/application/index.d.ts +++ /dev/null @@ -1,136 +0,0 @@ -declare module '@ember/application' { - import Engine from '@ember/engine'; - import ApplicationInstance from '@ember/application/instance'; - import EventDispatcher from '@ember/application/-private/event-dispatcher'; - import { EventDispatcherEvents } from '@ember/application/types'; - import Router from '@ember/routing/router'; - import Registry from '@ember/application/-private/registry'; - import { AnyFn } from 'ember/-private/type-utils'; - import Owner, { Resolver } from '@ember/owner'; - import type GlimmerComponent from '@glimmer/component'; - import EmberObject from '@ember/object'; - - // Shut off default exporting; we don't want anything but the *intended* - // public API present. - export {}; - - /** - * An instance of Ember.Application is the starting point for every Ember application. It helps to - * instantiate, initialize and coordinate the many objects that make up your app. - */ - export default class Application extends Engine { - /** - * Call advanceReadiness after any asynchronous setup logic has completed. - * Each call to deferReadiness must be matched by a call to advanceReadiness - * or the application will never become ready and routing will not begin. - */ - advanceReadiness(): void; - /** - * Use this to defer readiness until some condition is true. - * - * This allows you to perform asynchronous setup logic and defer - * booting your application until the setup has finished. - * - * However, if the setup requires a loading UI, it might be better - * to use the router for this purpose. - */ - deferReadiness(): void; - /** - * defines an injection or typeInjection - */ - inject(factoryNameOrType: string, property: string, injectionName: string): void; - /** - * This injects the test helpers into the window's scope. If a function of the - * same name has already been defined it will be cached (so that it can be reset - * if the helper is removed with `unregisterHelper` or `removeTestHelpers`). - * Any callbacks registered with `onInjectHelpers` will be called once the - * helpers have been injected. - */ - injectTestHelpers(): void; - /** - * registers a factory for later injection - * @param fullName type:name (e.g., 'model:user') - * @param factory (e.g., App.Person) - */ - register( - fullName: string, - factory: unknown, - options?: { singleton?: boolean | undefined; instantiate?: boolean | undefined } - ): void; - /** - * This removes all helpers that have been registered, and resets and functions - * that were overridden by the helpers. - */ - removeTestHelpers(): void; - /** - * Reset the application. This is typically used only in tests. - */ - reset(): void; - /** - * This hook defers the readiness of the application, so that you can start - * the app when your tests are ready to run. It also sets the router's - * location to 'none', so that the window's location will not be modified - * (preventing both accidental leaking of state between tests and interference - * with your testing framework). - */ - setupForTesting(): void; - /** - * The DOM events for which the event dispatcher should listen. - */ - customEvents: EventDispatcherEvents; - /** - * The Ember.EventDispatcher responsible for delegating events to this application's views. - */ - eventDispatcher: EventDispatcher; - /** - * Set this to provide an alternate class to `DefaultResolver` - */ - resolver: Resolver | null; - /** - * The root DOM element of the Application. This can be specified as an - * element or a jQuery-compatible selector string. - * - * This is the element that will be passed to the Application's, eventDispatcher, - * which sets up the listeners for event delegation. Every view in your application - * should be a child of the element you specify here. - */ - rootElement: HTMLElement | string; - /** - * Called when the Application has become ready. - * The call will be delayed until the DOM has become ready. - */ - ready: AnyFn; - /** - * Application's router. - */ - Router: Router; - registry: Registry; - /** - * Initialize the application and return a promise that resolves with the `Application` - * object when the boot process is complete. - */ - boot(): Promise; - /** - * Create an ApplicationInstance for this Application. - */ - buildInstance(options?: object): ApplicationInstance; - } - - /** - * Framework objects in an Ember application (components, services, routes, etc.) - * are created via a factory and dependency injection system. Each of these - * objects is the responsibility of an "owner", which handled its - * instantiation and manages its lifetime. - * - * @deprecated Use `import { getOwner } from '@ember/owner';` instead. - */ - export function getOwner(object: object): Owner | undefined; - - /** - * `setOwner` forces a new owner on a given object instance. This is primarily - * useful in some testing cases. - * - * @deprecated Use `import { setOwner } from '@ember/owner';` instead. - */ - export function setOwner(object: object, owner: Owner): void; -} diff --git a/types/preview/@ember/application/instance.d.ts b/types/preview/@ember/application/instance.d.ts deleted file mode 100644 index 37b60353c6f..00000000000 --- a/types/preview/@ember/application/instance.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module '@ember/application/instance' { - import EngineInstance from '@ember/engine/instance'; - - /** - * The `ApplicationInstance` encapsulates all of the stateful aspects of a - * running `Application`. - */ - export default class ApplicationInstance extends EngineInstance {} -} diff --git a/types/preview/@ember/application/types.d.ts b/types/preview/@ember/application/types.d.ts deleted file mode 100644 index fa3692e2458..00000000000 --- a/types/preview/@ember/application/types.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -declare module '@ember/application/types' { - export interface EventDispatcherEvents { - touchstart?: string | null | undefined; - touchmove?: string | null | undefined; - touchend?: string | null | undefined; - touchcancel?: string | null | undefined; - keydown?: string | null | undefined; - keyup?: string | null | undefined; - keypress?: string | null | undefined; - mousedown?: string | null | undefined; - mouseup?: string | null | undefined; - contextmenu?: string | null | undefined; - click?: string | null | undefined; - dblclick?: string | null | undefined; - focusin?: string | null | undefined; - focusout?: string | null | undefined; - submit?: string | null | undefined; - input?: string | null | undefined; - change?: string | null | undefined; - dragstart?: string | null | undefined; - drag?: string | null | undefined; - dragenter?: string | null | undefined; - dragleave?: string | null | undefined; - dragover?: string | null | undefined; - drop?: string | null | undefined; - dragend?: string | null | undefined; - [event: string]: string | null | undefined; - } -} diff --git a/types/preview/@ember/array/-private/enumerable.d.ts b/types/preview/@ember/array/-private/enumerable.d.ts deleted file mode 100644 index 36b0120eb94..00000000000 --- a/types/preview/@ember/array/-private/enumerable.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -declare module '@ember/array/-private/enumerable' { - import Mixin from '@ember/object/mixin'; - - /** - * The methods in this mixin have been moved to `MutableArray`. This mixin has - * been intentionally preserved to avoid breaking `Enumerable.detect` checks - * until the community migrates away from them. - */ - interface Enumerable {} - - const Enumerable: Mixin; - export default Enumerable; -} diff --git a/types/preview/@ember/array/-private/mutable-enumerable.d.ts b/types/preview/@ember/array/-private/mutable-enumerable.d.ts deleted file mode 100644 index d3bc4972cc3..00000000000 --- a/types/preview/@ember/array/-private/mutable-enumerable.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -declare module '@ember/array/-private/mutable-enumerable' { - import Mixin from '@ember/object/mixin'; - import Enumerable from '@ember/array/-private/enumerable'; - - /** - * This Mixin exists for historical purposes only, and so that someone walking - * the types for Ember's arrays sees the same types as those which appear in - * the runtime hierarchy. - */ - interface MutableEnumerable extends Enumerable {} - const MutableEnumerable: Mixin; - export default MutableEnumerable; -} diff --git a/types/preview/@ember/array/-private/native-array.d.ts b/types/preview/@ember/array/-private/native-array.d.ts deleted file mode 100644 index d7be1f52cd3..00000000000 --- a/types/preview/@ember/array/-private/native-array.d.ts +++ /dev/null @@ -1,181 +0,0 @@ -declare module '@ember/array/-private/native-array' { - import Observable from '@ember/object/observable'; - import EmberArray from '@ember/array'; - import MutableArray from '@ember/array/mutable'; - import Mixin from '@ember/object/mixin'; - - // Get an alias to the global Array type to use in inner scope below. - type Array = T[]; - - type AnyArray = EmberArray | Array | ReadonlyArray; - - /** - * The final definition of NativeArray removes all native methods. This is the list of removed methods - * when run in Chrome 106. - */ - type IGNORED_MUTABLE_ARRAY_METHODS = - | 'length' - | 'slice' - | 'indexOf' - | 'lastIndexOf' - | 'forEach' - | 'map' - | 'filter' - | 'find' - | 'every' - | 'reduce' - | 'includes'; - - /** - * These additional items must be redefined since `Omit` causes methods that return `this` to return the - * type at the time of the Omit. - */ - type RETURN_SELF_ARRAY_METHODS = - | '[]' - | 'clear' - | 'insertAt' - | 'removeAt' - | 'pushObjects' - | 'unshiftObjects' - | 'reverseObjects' - | 'setObjects' - | 'removeObject' - | 'removeObjects' - | 'addObject' - | 'addObjects' - | 'setEach'; - - // This is the same as MutableArray, but removes the actual native methods that exist on Array.prototype. - interface MutableArrayWithoutNative - extends Omit, IGNORED_MUTABLE_ARRAY_METHODS | RETURN_SELF_ARRAY_METHODS> { - /** - * Remove all elements from the array. This is useful if you - * want to reuse an existing array without having to recreate it. - */ - clear(): this; - /** - * This will use the primitive `replace()` method to insert an object at the - * specified index. - */ - insertAt(idx: number, object: T): this; - /** - * Remove an object at the specified index using the `replace()` primitive - * method. You can pass either a single index, or a start and a length. - */ - removeAt(start: number, len?: number): this; - /** - * Add the objects in the passed numerable to the end of the array. Defers - * notifying observers of the change until all objects are added. - */ - pushObjects(objects: AnyArray): this; - /** - * Adds the named objects to the beginning of the array. Defers notifying - * observers until all objects have been added. - */ - unshiftObjects(objects: AnyArray): this; - /** - * Reverse objects in the array. Works just like `reverse()` but it is - * KVO-compliant. - */ - reverseObjects(): this; - /** - * Replace all the receiver's content with content of the argument. - * If argument is an empty array receiver will be cleared. - */ - setObjects(objects: AnyArray): this; - /** - Remove all occurrences of an object in the array. - - ```javascript - let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago']; - - cities.removeObject('Chicago'); // ['Berlin', 'Lima'] - cities.removeObject('Lima'); // ['Berlin'] - cities.removeObject('Tokyo') // ['Berlin'] - ``` - - @method removeObject - @param {*} obj object to remove - @return {EmberArray} receiver - @public - */ - removeObject(object: T): this; - /** - * Removes each object in the passed array from the receiver. - */ - removeObjects(objects: AnyArray): this; - /** - Push the object onto the end of the array if it is not already - present in the array. - - ```javascript - let cities = ['Chicago', 'Berlin']; - - cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima'] - cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima'] - ``` - - @method addObject - @param {*} obj object to add, if not already present - @return {EmberArray} receiver - @public - */ - addObject(obj: T): this; - /** - * Adds each object in the passed enumerable to the receiver. - */ - addObjects(objects: AnyArray): this; - /** - Sets the value on the named property for each member. This is more - ergonomic than using other methods defined on this helper. If the object - implements Observable, the value will be changed to `set(),` otherwise - it will be set directly. `null` objects are skipped. - - ```javascript - let people = [{name: 'Joe'}, {name: 'Matt'}]; - - people.setEach('zipCode', '10011'); - // [{name: 'Joe', zipCode: '10011'}, {name: 'Matt', zipCode: '10011'}]; - ``` - - @method setEach - @param {String} key The key to set - @param {Object} value The object to set - @return {Object} receiver - @public - */ - setEach(key: K, value: T[K]): this; - /** - This is the handler for the special array content property. If you get - this property, it will return this. If you set this property to a new - array, it will replace the current content. - - ```javascript - let peopleToMoon = ['Armstrong', 'Aldrin']; - - peopleToMoon.get('[]'); // ['Armstrong', 'Aldrin'] - - peopleToMoon.set('[]', ['Collins']); // ['Collins'] - peopleToMoon.get('[]'); // ['Collins'] - ``` - - @property [] - @return this - @public - */ - get '[]'(): this; - set '[]'(newValue: T[] | this); - } - - /** - * The NativeArray mixin contains the properties needed to make the native - * Array support Ember.MutableArray and all of its dependent APIs. Unless you - * have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to - * false, this will be applied automatically. Otherwise you can apply the mixin - * at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. - */ - interface NativeArray extends Array, Observable, MutableArrayWithoutNative {} - - const NativeArray: Mixin; - export default NativeArray; -} diff --git a/types/preview/@ember/array/index.d.ts b/types/preview/@ember/array/index.d.ts deleted file mode 100644 index 5a7aa94dc45..00000000000 --- a/types/preview/@ember/array/index.d.ts +++ /dev/null @@ -1,251 +0,0 @@ -declare module '@ember/array' { - import { MethodNamesOf, MethodParams, MethodReturns } from 'ember/-private/type-utils'; - import Mixin from '@ember/object/mixin'; - import Enumerable from '@ember/array/-private/enumerable'; - import NativeArray from '@ember/array/-private/native-array'; - - /** - * This module implements Observer-friendly Array-like behavior. This mixin is picked up by the - * Array class as well as other controllers, etc. that want to appear to be arrays. - */ - interface Array extends Enumerable { - /** - * __Required.__ You must implement this method to apply this mixin. - */ - length: number; - /** - * Returns the object at the given `index`. If the given `index` is negative - * or is greater or equal than the array length, returns `undefined`. - */ - objectAt(idx: number): T | undefined; - /** - * This returns the objects at the specified indexes, using `objectAt`. - */ - objectsAt(indexes: number[]): Array; - /** - * Helper method returns the first object from a collection. This is usually - * used by bindings and other parts of the framework to extract a single - * object if the enumerable contains only one item. - */ - firstObject: T | undefined; - /** - * Helper method returns the last object from a collection. If your enumerable - * contains only one object, this method should always return that object. - * If your enumerable is empty, this method should return `undefined`. - */ - lastObject: T | undefined; - /** - * Returns a new array that is a slice of the receiver. This implementation - * uses the observable array methods to retrieve the objects for the new - * slice. - */ - slice(beginIndex?: number, endIndex?: number): NativeArray; - /** - * Returns the index of the given object's first occurrence. - * If no `startAt` argument is given, the starting location to - * search is 0. If it's negative, will count backward from - * the end of the array. Returns -1 if no match is found. - */ - indexOf(searchElement: T, fromIndex?: number): number; - /** - * Returns the index of the given object's last occurrence. - * If no `startAt` argument is given, the search starts from - * the last position. If it's negative, will count backward - * from the end of the array. Returns -1 if no match is found. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - /** - * Iterates through the enumerable, calling the passed function on each - * item. This method corresponds to the `forEach()` method defined in - * JavaScript 1.6. - */ - forEach( - callback: (this: Target, item: T, index: number, arr: this) => void, - target?: Target - ): this; - /** - * Alias for `mapBy` - */ - getEach(key: K): NativeArray; - /** - * Sets the value on the named property for each member. This is more - * ergonomic than using other methods defined on this helper. If the object - * implements Ember.Observable, the value will be changed to `set(),` otherwise - * it will be set directly. `null` objects are skipped. - */ - setEach(key: K, value: T[K]): this; - /** - * Maps all of the items in the enumeration to another value, returning - * a new array. This method corresponds to `map()` defined in JavaScript 1.6. - */ - map( - callback: (this: Target, item: T, index: number, arr: this) => U, - target?: Target - ): NativeArray; - /** - * Similar to map, this specialized function returns the value of the named - * property on all items in the enumeration. - */ - mapBy(key: K): NativeArray; - mapBy(key: string): NativeArray; - /** - * Returns an array with all of the items in the enumeration that the passed - * function returns true for. This method corresponds to `filter()` defined in - * JavaScript 1.6. - */ - filter( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): NativeArray; - /** - * Returns an array with all of the items in the enumeration where the passed - * function returns false. This method is the inverse of filter(). - */ - reject( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): NativeArray; - /** - * Returns an array with just the items with the matched property. You - * can pass an optional second argument with the target value. Otherwise - * this will match any property that evaluates to `true`. - */ - filterBy(key: K, value?: T[K]): NativeArray; - filterBy(key: string, value?: unknown): NativeArray; - /** - * Returns an array with the items that do not have truthy values for - * key. You can pass an optional second argument with the target value. Otherwise - * this will match any property that evaluates to false. - */ - rejectBy(key: K, value?: T[K]): NativeArray; - rejectBy(key: string, value?: unknown): NativeArray; - /** - * Returns the first item in the array for which the callback returns true. - * This method works similar to the `filter()` method defined in JavaScript 1.6 - * except that it will stop working on the array once a match is found. - */ - find( - predicate: (this: void, value: T, index: number, obj: T[]) => value is S, - thisArg?: Target - ): S | undefined; - find( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): T | undefined; - /** - * Returns the first item with a property matching the passed value. You - * can pass an optional second argument with the target value. Otherwise - * this will match any property that evaluates to `true`. - */ - findBy(key: K, value?: T[K]): T | undefined; - findBy(key: string, value?: unknown): T | undefined; - /** - * Returns `true` if the passed function returns true for every item in the - * enumeration. This corresponds with the `every()` method in JavaScript 1.6. - */ - every( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): boolean; - /** - * Returns `true` if the passed property resolves to the value of the second - * argument for all items in the enumerable. This method is often simpler/faster - * than using a callback. - */ - isEvery(key: K, value?: T[K]): boolean; - isEvery(key: string, value?: unknown): boolean; - /** - * Returns `true` if the passed function returns true for any item in the - * enumeration. - */ - any( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): boolean; - /** - * Returns `true` if the passed property resolves to the value of the second - * argument for any item in the enumerable. This method is often simpler/faster - * than using a callback. - */ - isAny(key: K, value?: T[K]): boolean; - isAny(key: string, value?: unknown): boolean; - /** - * This will combine the values of the enumerator into a single value. It - * is a useful way to collect a summary value from an enumeration. This - * corresponds to the `reduce()` method defined in JavaScript 1.8. - */ - reduce( - callback: (summation: V, current: T, index: number, arr: this) => V, - initialValue?: V - ): V; - /** - * Invokes the named method on every object in the receiver that - * implements it. This method corresponds to the implementation in - * Prototype 1.6. - */ - invoke>( - methodName: M, - ...args: MethodParams - ): NativeArray>; - /** - * Simply converts the enumerable into a genuine array. The order is not - * guaranteed. Corresponds to the method implemented by Prototype. - */ - toArray(): T[]; - /** - * Returns a copy of the array with all `null` and `undefined` elements removed. - */ - compact(): NativeArray>; - /** - * Returns `true` if the passed object can be found in the enumerable. - */ - includes(searchElement: T, fromIndex?: number): boolean; - /** - * Converts the enumerable into an array and sorts by the keys - * specified in the argument. - */ - sortBy(...properties: string[]): T[]; - /** - * Returns a new enumerable that excludes the passed value. The default - * implementation returns an array regardless of the receiver type. - * If the receiver does not contain the value it returns the original enumerable. - */ - without(value: T): NativeArray; - /** - * Returns a new enumerable that contains only unique values. The default - * implementation returns an array regardless of the receiver type. - */ - uniq(): NativeArray; - /** - * Returns a new enumerable that contains only items containing a unique property value. - * The default implementation returns an array regardless of the receiver type. - */ - uniqBy(property: string): NativeArray; - uniqBy(callback: (value: T) => unknown): NativeArray; - /** - * This is the handler for the special array content property. If you get - * this property, it will return this. If you set this property to a new - * array, it will replace the current content. - */ - get '[]'(): this; - set '[]'(newValue: T[] | Array); - } - // Ember.Array rather than Array because the `array-type` lint rule doesn't realize the global is shadowed - const Array: Mixin; - export default Array; - - /** - * Creates an `Ember.NativeArray` from an Array like object. - * Does not modify the original object's contents. Ember.A is not needed if - * `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However, - * it is recommended that you use Ember.A when creating addons for - * ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES` - * will be `true`. - */ - export function A(arr?: T[]): NativeArray; - - /** - * Returns true if the passed object is an array or Array-like. - */ - export function isArray(obj: unknown): obj is ArrayLike; -} diff --git a/types/preview/@ember/array/mutable.d.ts b/types/preview/@ember/array/mutable.d.ts deleted file mode 100644 index 3890fe05da6..00000000000 --- a/types/preview/@ember/array/mutable.d.ts +++ /dev/null @@ -1,94 +0,0 @@ -declare module '@ember/array/mutable' { - import Mixin from '@ember/object/mixin'; - import MutableEnumerable from '@ember/array/-private/mutable-enumerable'; - import EmberArray from '@ember/array'; - - type AnyArray = EmberArray | Array; - - /** - * This mixin defines the API for modifying array-like objects. These methods - * can be applied only to a collection that keeps its items in an ordered set. - * It builds upon the Array mixin and adds methods to modify the array. - * One concrete implementations of this class include ArrayProxy. - */ - interface MutableArray extends EmberArray, MutableEnumerable { - /** - * __Required.__ You must implement this method to apply this mixin. - */ - replace(idx: number, amt: number, objects: T[]): void; - /** - * Remove all elements from the array. This is useful if you - * want to reuse an existing array without having to recreate it. - */ - clear(): this; - /** - * This will use the primitive `replace()` method to insert an object at the - * specified index. - */ - insertAt(idx: number, object: T): this; - /** - * Remove an object at the specified index using the `replace()` primitive - * method. You can pass either a single index, or a start and a length. - */ - removeAt(start: number, len?: number): this; - /** - * Push the object onto the end of the array. Works just like `push()` but it - * is KVO-compliant. - */ - pushObject(obj: T): T; - /** - * Add the objects in the passed numerable to the end of the array. Defers - * notifying observers of the change until all objects are added. - */ - pushObjects(objects: AnyArray): this; - /** - * Pop object from array or nil if none are left. Works just like `pop()` but - * it is KVO-compliant. - */ - popObject(): T | null | undefined; - /** - * Shift an object from start of array or nil if none are left. Works just - * like `shift()` but it is KVO-compliant. - */ - shiftObject(): T | null | undefined; - /** - * Unshift an object to start of array. Works just like `unshift()` but it is - * KVO-compliant. - */ - unshiftObject(obj: T): T; - /** - * Adds the named objects to the beginning of the array. Defers notifying - * observers until all objects have been added. - */ - unshiftObjects(objects: AnyArray): this; - /** - * Reverse objects in the array. Works just like `reverse()` but it is - * KVO-compliant. - */ - reverseObjects(): this; - /** - * Replace all the receiver's content with content of the argument. - * If argument is an empty array receiver will be cleared. - */ - setObjects(objects: AnyArray): this; - /** - * __Required.__ You must implement this method to apply this mixin. - */ - removeObject(object: T): T; - /** - * Removes each object in the passed array from the receiver. - */ - removeObjects(objects: AnyArray): this; - /** - * __Required.__ You must implement this method to apply this mixin. - */ - addObject(object: T): this; - /** - * Adds each object in the passed enumerable to the receiver. - */ - addObjects(objects: AnyArray): this; - } - - const MutableArray: Mixin; - export default MutableArray; -} diff --git a/types/preview/@ember/array/proxy.d.ts b/types/preview/@ember/array/proxy.d.ts deleted file mode 100644 index 37efc898204..00000000000 --- a/types/preview/@ember/array/proxy.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -declare module '@ember/array/proxy' { - import Array from '@ember/array'; - import type MutableArray from '@ember/array/mutable'; - import EmberObject from '@ember/object'; - - /** - * An ArrayProxy wraps any other object that is a native or Ember `Array` - * (checked with [`Ember.isArray`](https://api.emberjs.com/ember/release/functions/@ember%2Farray/isArray)), - * forwarding all requests. This makes it very useful for a number of - * binding use cases or other cases where being able to swap out the - * underlying array is useful. - * - * NOTE: Attempting to mutate the underlying content of an object that - * is not a `MutableArray` (e.g. a native Javascript Array) may not - * behave as expected. [`Ember.A`](https://api.emberjs.com/ember/release/functions/@ember%2Farray/A) - * may be used in this case. - */ - export default interface ArrayProxy extends MutableArray {} - export default class ArrayProxy extends EmberObject { - content: T[] | Array; - - /** - * Should actually retrieve the object at the specified index from the - * content. You can override this method in subclasses to transform the - * content item to something new. - */ - objectAtContent(idx: number): T | undefined; - } -} diff --git a/types/preview/@ember/component/-private/class-names-support.d.ts b/types/preview/@ember/component/-private/class-names-support.d.ts deleted file mode 100644 index a8dc9cf4e28..00000000000 --- a/types/preview/@ember/component/-private/class-names-support.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -declare module '@ember/component/-private/class-names-support' { - import Mixin from '@ember/object/mixin'; - - interface ClassNamesSupport { - /** - * A list of properties of the view to apply as class names. If the property is a string value, - * the value of that string will be applied as a class name. - * - * If the value of the property is a Boolean, the name of that property is added as a dasherized - * class name. - * - * If you would prefer to use a custom value instead of the dasherized property name, you can - * pass a binding like this: `classNameBindings: ['isUrgent:urgent']` - * - * This list of properties is inherited from the component's superclasses as well. - */ - classNameBindings: string[]; - /** - * Standard CSS class names to apply to the view's outer element. This - * property automatically inherits any class names defined by the view's - * superclasses as well. - */ - classNames: string[]; - } - const ClassNamesSupport: Mixin; - export default ClassNamesSupport; -} diff --git a/types/preview/@ember/component/-private/core-view.d.ts b/types/preview/@ember/component/-private/core-view.d.ts deleted file mode 100644 index cc1b307640f..00000000000 --- a/types/preview/@ember/component/-private/core-view.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -declare module '@ember/component/-private/core-view' { - import EmberObject from '@ember/object'; - import type Evented from '@ember/object/evented'; - import type ActionHandler from '@ember/object/-private/action-handler'; - - /** - * Ember.CoreView is an abstract class that exists to give view-like behavior to both Ember's main - * view class Ember.Component and other classes that don't need the full functionality of Ember.Component. - * - * Unless you have specific needs for CoreView, you will use Ember.Component in your applications. - */ - export default class CoreView extends EmberObject {} - export default interface CoreView extends Evented, ActionHandler {} -} diff --git a/types/preview/@ember/component/-private/glimmer-interfaces.d.ts b/types/preview/@ember/component/-private/glimmer-interfaces.d.ts deleted file mode 100644 index 2298c591b64..00000000000 --- a/types/preview/@ember/component/-private/glimmer-interfaces.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -declare module '@ember/component/-private/glimmer-interfaces' { - // NOTE: this is a bare-minimum subset of the definitions of the types in - // `@glimmer/interfaces`, supplied to make the public types in this package - // accurate. - - // This is only present to "brand" the type, and it brands it in a way that - // matches [the implementation][1], which *also* uses it as a type-only brand. - // - // [1]: https://github.com/glimmerjs/glimmer-vm/blob/d6d776cf3797dafa923bcdad47e1897231ef6539/packages/%40glimmer/interfaces/lib/managers/capabilities.d.ts#L1 - const CAPABILITIES: unique symbol; - - export interface Capabilities { - [CAPABILITIES]: true; - } - - export interface Arguments { - positional: readonly unknown[]; - named: Record; - } - - export interface ComponentCapabilitiesVersions { - '3.4': { - asyncLifecycleCallbacks?: boolean; - destructor?: boolean; - }; - - '3.13': { - asyncLifecycleCallbacks?: boolean; - destructor?: boolean; - updateHook?: boolean; - }; - } - - export interface ComponentCapabilities extends Capabilities { - asyncLifeCycleCallbacks: boolean; - destructor: boolean; - updateHook: boolean; - } - - export interface ComponentManager { - capabilities: ComponentCapabilities; - createComponent(factory: object, args: Arguments): ComponentStateBucket; - getContext(instance: ComponentStateBucket): unknown; - } - - export interface TemplateFactory { - __htmlbars_inline_precompile_template_factory: any; - } -} diff --git a/types/preview/@ember/component/-private/signature-utils.d.ts b/types/preview/@ember/component/-private/signature-utils.d.ts deleted file mode 100644 index e21679429e4..00000000000 --- a/types/preview/@ember/component/-private/signature-utils.d.ts +++ /dev/null @@ -1,107 +0,0 @@ -declare module '@ember/component/-private/signature-utils' { - /** - * @module Type utilities for signatures - */ - - // Type-only "symbol" to use with `EmptyObject` below, so that it is *not* - // equivalent to an empty interface. - const Empty: unique symbol; - - /** - * This provides us a way to have a "fallback" which represents an empty object, - * without the downsides of how TS treats `{}`. Specifically: this will - * correctly leverage "excess property checking" so that, given a component - * which has no named args, if someone invokes it with any named args, they will - * get a type error. - * - * @internal This is exported so declaration emit works (if it were not emitted, - * declarations which fall back to it would not work). It is *not* intended for - * public usage, and the specific mechanics it uses may change at any time. - * The location of this export *is* part of the public API, because moving it - * will break existing declarations, but is not legal for end users to import - * themselves, so ***DO NOT RELY ON IT***. - */ - export interface EmptyObject { - [Empty]?: true; - } - - type DefaultPositional = unknown[]; - type DefaultNamed = EmptyObject; - - type GetOrElse = K extends keyof Obj ? Obj[K] : Fallback; - - /** Given a signature `S`, get back the `Args` type. */ - type ArgsFor = 'Args' extends keyof S - ? { - Named: GetOrElse; - Positional: GetOrElse; - } - : { Named: DefaultNamed; Positional: [] }; - - interface LegacyArgsFor { - Named: GetOrElse; - Positional: GetOrElse; - } - - // This type allows us to present a slightly-less-obtuse error message - // when attempting to resolve the signature of a helper that doesn't have - // one declared from within a tool like Glint. - const BadType: unique symbol; - /** @internal This is *only* exported to use in tests! */ - export interface BadType { - [BadType]: Message; - } - - interface MissingSignatureArgs { - Named: BadType<'This helper is missing a signature'>; - Positional: unknown[]; - } - - /** - * Given any allowed shorthand form of a signature, desugars it to its full - * expanded type. - * - * @internal This is only exported so we can avoid duplicating it in - * [Glint](https://github.com/typed-ember/glint) or other such tooling. It is - * *not* intended for public usage, and the specific mechanics it uses may - * change at any time. Although the signature produced by is part of Glimmer's - * public API the existence and mechanics of this specific symbol are *not*, - * so ***DO NOT RELY ON IT***. - */ - // This is similar but not identical to the `ExpandSignature` type used in the - // Glimmer Component API: it uses the same basic mechanics, but does not have - // an identical signature because we had not yet normalized the `Signature` when - // we designed the first pass of this. In the future, we will be able to make - // all `ExpandSignature` types fully general to work with *any* invokable. But - // "future" here probably means Ember v5. :sobbing: - // prettier-ignore - export interface ExpandSignature { - Args: - // Is this the default (i.e. unspecified) signature? - // Then return our special "missing signature" type - unknown extends T ? MissingSignatureArgs : - // Is this a `Signature`? Then use `Signature` args - keyof T extends 'Args' | 'Return' ? ArgsFor : - // Otherwise fall back to classic `Args`. - LegacyArgsFor; - Return: 'Return' extends keyof T ? T['Return'] : unknown; -} - - // The `unknown extends S` checks on both of these are here to preserve backward - // compatibility with the existing non-`Signature` definition. When migrating - // into Ember or otherwise making a breaking change, we can drop the "default" - // in favor of just using `ExpandSignature`. - // prettier-ignore - export type NamedArgs = - unknown extends S - ? Record - : ExpandSignature['Args']['Named']; - - // prettier-ignore - export type PositionalArgs = - unknown extends S - ? unknown[] - : ExpandSignature['Args']['Positional']; - - export type Return = GetOrElse; -} diff --git a/types/preview/@ember/component/-private/view-mixin.d.ts b/types/preview/@ember/component/-private/view-mixin.d.ts deleted file mode 100644 index 152f75af973..00000000000 --- a/types/preview/@ember/component/-private/view-mixin.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -declare module '@ember/component/-private/view-mixin' { - import Mixin from '@ember/object/mixin'; - - interface ViewMixin { - /** - * A list of properties of the view to apply as attributes. If the property - * is a string value, the value of that string will be applied as the value - * for an attribute of the property's name. - */ - attributeBindings: string[]; - /** - * Returns the current DOM element for the view. - */ - element: Element; - /** - * The HTML `id` of the view's element in the DOM. You can provide this - * value yourself but it must be unique (just as in HTML): - */ - elementId: string; - /** - * Tag name for the view's outer element. The tag name is only used when an - * element is first created. If you change the `tagName` for an element, you - * must destroy and recreate the view element. - */ - tagName: string; - /** - * Renders the view again. This will work regardless of whether the - * view is already in the DOM or not. If the view is in the DOM, the - * rendering process will be deferred to give bindings a chance - * to synchronize. - */ - rerender(): void; - /** - * Called when a view is going to insert an element into the DOM. - */ - willInsertElement(): void; - /** - * Called when the element of the view has been inserted into the DOM. - * Override this function to do any set up that requires an element - * in the document body. - */ - didInsertElement(): void; - /** - * Called when the view is about to rerender, but before anything has - * been torn down. This is a good opportunity to tear down any manual - * observers you have installed based on the DOM state - */ - willClearRender(): void; - /** - * Called when the element of the view is going to be destroyed. Override - * this function to do any teardown that requires an element, like removing - * event listeners. - */ - willDestroyElement(): void; - } - const ViewMixin: Mixin; - - export default ViewMixin; -} diff --git a/types/preview/@ember/component/helper.d.ts b/types/preview/@ember/component/helper.d.ts deleted file mode 100644 index d4c00902a8c..00000000000 --- a/types/preview/@ember/component/helper.d.ts +++ /dev/null @@ -1,122 +0,0 @@ -declare module '@ember/component/helper' { - import EmberObject from '@ember/object'; - import { Opaque } from 'ember/-private/type-utils'; - import { - DefaultNamed, - DefaultPositional, - EmptyObject, - ExpandSignature, - NamedArgs, - PositionalArgs, - Return, - } from '@ember/component/-private/signature-utils'; - - // Immediately re-export these. - export { EmptyObject, ExpandSignature }; - - /** - * The public shape of a helper. - * @deprecated Do not use this directly. Instead, write a `Signature` with the - * "normal" signature shape: `Args: { Named: { ... }, Positional: [...] }`. - */ - export interface HelperSignature { - NamedArgs?: DefaultNamed; - PositionalArgs?: DefaultPositional; - Return?: unknown; - } - - /** - * Ember Helpers are functions that can compute values, and are used in templates. - * For example, this code calls a helper named `format-currency`: - */ - export default class Helper extends EmberObject { - /** - * In many cases, the ceremony of a full `Ember.Helper` class is not required. - * The `helper` method create pure-function helpers without instances. For - * example: - */ - static helper

( - helper: (positional: P, named: N) => R - ): Helper<{ Args: { Positional: P; Named: N }; Return: R }>; - /** - * Override this function when writing a class-based helper. - */ - compute(positional: PositionalArgs, named: NamedArgs): Return; - /** - * On a class-based helper, it may be useful to force a recomputation of that - * helpers value. This is akin to `rerender` on a component. - */ - recompute(): void; - } - - // The generic here is for a *signature*: a way to hang information for tools - // like Glint which can provide type checking for component templates using - // information supplied via this generic. While it may appear useless on this - // class definition and extension, it is used by external tools and should not - // be removed. - export default interface Helper extends Opaque {} - - // This type exists to provide a non-user-constructible, non-subclassable - // type representing the conceptual "instance type" of a function helper. - // The abstract field of type `never` presents subclassing in userspace of - // the value returned from `helper()`. By extending `Helper`, any - // augmentations of the `Helper` type performed by tools like Glint will - // also apply to function-based helpers as well. - export abstract class FunctionBasedHelperInstance extends Helper { - protected abstract __concrete__: never; - } - - /** - * The type of a function-based helper. - * - * @note This is *not* user-constructible: it is exported only so that the type - * returned by the `helper` function can be named (and indeed can be exported - * like `export default helper(...)` safely). - */ - // Making `FunctionBasedHelper` a bare constructor type allows for type - // parameters to be preserved when `helper()` is passed a generic function. - // By making it `abstract` and impossible to subclass (see above), we prevent - // users from attempting to instantiate a return value from `helper()`. - export type FunctionBasedHelper = abstract new () => FunctionBasedHelperInstance; - - /** - * In many cases, the ceremony of a full `Helper` class is not required. - * The `helper` method create pure-function helpers without instances. For - * example: - * ```app/helpers/format-currency.js - * import { helper } from '@ember/component/helper'; - * export default helper(function(params, hash) { - * let cents = params[0]; - * let currency = hash.currency; - * return `${currency}${cents * 0.01}`; - * }); - * ``` - */ - // This overload allows users to write types directly on the callback passed to - // the `helper` function and infer the resulting type correctly. - export function helper

( - helperFn: (positional: P, named: N) => R - ): FunctionBasedHelper<{ - Args: { - Positional: P; - Named: N; - }; - Return: R; - }>; - - // This overload allows users to provide a `Signature` type explicitly at the - // helper definition site, e.g. `helper((pos, named) => {...})`. **Note:** - // this overload must appear second, since TS' inference engine will not - // correctly infer the type of `S` here from the types on the supplied callback. - export function helper( - helperFn: (positional: PositionalArgs, named: NamedArgs) => Return - ): FunctionBasedHelper<{ - Args: { - Positional: PositionalArgs; - Named: NamedArgs; - }; - Return: Return; - }>; - - export {}; -} diff --git a/types/preview/@ember/component/index.d.ts b/types/preview/@ember/component/index.d.ts deleted file mode 100644 index 4c0c824917d..00000000000 --- a/types/preview/@ember/component/index.d.ts +++ /dev/null @@ -1,164 +0,0 @@ -declare module '@ember/component' { - import CoreView from '@ember/component/-private/core-view'; - import ClassNamesSupport from '@ember/component/-private/class-names-support'; - import { TemplateFactory } from '@ember/component/-private/glimmer-interfaces'; - import ViewMixin from '@ember/component/-private/view-mixin'; - import { ComponentManager, Capabilities } from '@ember/component/-private/glimmer-interfaces'; - import { Opaque } from 'ember/-private/type-utils'; - - // Re-export these types so people can use them! - export { ComponentManager, Capabilities }; - - // The generic here is for a *signature: a way to hang information for tools - // like Glint which can provide typey checking for component templates using - // information supplied via this generic. While it may appear useless on this - // class definition and extension, it is used by external tools and should not - // be removed. - export default interface Component extends ViewMixin, ClassNamesSupport, Opaque {} - export default class Component extends CoreView { - // methods - readDOMAttr(name: string): string; - // properties - /** - * The WAI-ARIA role of the control represented by this view. For example, a button may have a - * role of type 'button', or a pane may have a role of type 'alertdialog'. This property is - * used by assistive software to help visually challenged users navigate rich web applications. - */ - ariaRole: string; - /** - * The HTML id of the component's element in the DOM. You can provide this value yourself but - * it must be unique (just as in HTML): - * - * If not manually set a default value will be provided by the framework. Once rendered an - * element's elementId is considered immutable and you should never change it. If you need - * to compute a dynamic value for the elementId, you should do this when the component or - * element is being instantiated: - */ - elementId: string; - /** - * A component may contain a layout. A layout is a regular template but supersedes the template - * property during rendering. It is the responsibility of the layout template to retrieve the - * template property from the component (or alternatively, call Handlebars.helpers.yield, - * {{yield}}) to render it in the correct location. This is useful for a component that has a - * shared wrapper, but which delegates the rendering of the contents of the wrapper to the - * template property on a subclass. - */ - layout: TemplateFactory | string; - /** - * Enables components to take a list of parameters as arguments. - */ - static positionalParams: string[] | string; - // events - /** - * Called when the attributes passed into the component have been updated. Called both during the - * initial render of a container and during a rerender. Can be used in place of an observer; code - * placed here will be executed every time any attribute updates. - */ - didReceiveAttrs(): void; - /** - * Called after a component has been rendered, both on initial render and in subsequent rerenders. - */ - didRender(): void; - /** - * Called when the component has updated and rerendered itself. Called only during a rerender, - * not during an initial render. - */ - didUpdate(): void; - /** - * Called when the attributes passed into the component have been changed. Called only during a - * rerender, not during an initial render. - */ - didUpdateAttrs(): void; - /** - * Called before a component has been rendered, both on initial render and in subsequent rerenders. - */ - willRender(): void; - /** - * Called when the component is about to update and rerender itself. Called only during a rerender, - * not during an initial render. - */ - willUpdate(): void; - - /** - * `reopen()` was deprecated and removed from `Component`. It is given an - * illegitimate type in these types so that you cannot call it or use it! - * Unfortunately, it cannot actually be *removed* from this type, because TS - * rightly complains that `Component` is no longer a valid subtype of the - * `EmberObject` base class, and will not let you use it. - */ - static reopen(): never; - } - - /** - * Associate a class with a component manager (an object that is responsible for - * coordinating the lifecycle events that occurs when invoking, rendering and - * re-rendering a component). - * - * @param managerFactory a function to create the owner for an object - * @param object the object to associate with the componetn manager - * @return the same object passed in, now associated with the manager - */ - export function setComponentManager( - managerFactory: (owner: unknown) => ComponentManager, - object: T - ): T; - - /** - * Takes a component class and returns the template associated with the given component class, - * if any, or one of its superclasses, if any, or undefined if no template association was found. - * - * @param object the component object - * @return the template factory of the given component - */ - export function getComponentTemplate(obj: object): TemplateFactory | undefined; - - export function setComponentTemplate(factory: TemplateFactory, obj: object): object; - - interface ComponentCapabilitiesVersions { - '3.4': { - asyncLifecycleCallbacks?: boolean; - destructor?: boolean; - }; - - '3.13': { - asyncLifecycleCallbacks?: boolean; - destructor?: boolean; - updateHook?: boolean; - }; - } - - interface ComponentCapabilities extends Capabilities { - asyncLifeCycleCallbacks: boolean; - destructor: boolean; - updateHook: boolean; - } - - export function capabilities( - managerAPI: Version, - options?: ComponentCapabilitiesVersions[Version] - ): ComponentCapabilities; - - // In normal TypeScript, these built-in components are essentially opaque tokens - // that just need to be importable. Declaring them with unique interfaces - // like this, however, gives tools like Glint (that DO have a richer - // notion of what they are) a place to install more detailed type information. - export interface Input extends Opaque<'component:input'> {} - export interface Textarea extends Opaque<'component:textarea'> {} - - /** - * The `Input` component lets you create an HTML `` element. - * - * @see https://api.emberjs.com/ember/4.1/classes/Ember.Templates.components/methods/Input?anchor=Input - */ - export const Input: Input; - - /** - * The `Textarea` component inserts a new instance of `