language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
emberjs
ember.js
bb0811dbf4928e251d897e2572d653680a46cdb1.json
Update preview type tests for array and mutable
types/preview/@ember/array/mutable.d.ts
@@ -1,7 +1,7 @@ -import Mixin from "@ember/object/mixin"; -import MutableEnumerable from "@ember/array/-private/mutable-enumerable"; +import Mixin from '@ember/object/mixin'; +import MutableEnumerable from '@ember/array/-private/mutable-enumerable'; import EmberArray from '@ember/array'; -import Enumerable from "@ember/array/-private/enumerable"; +import Enumerable from '@ember/array/-private/enumerable'; /** * This mixin defines the API for modifying array-like objects. These methods @@ -10,66 +10,66 @@ import Enumerable from "@ember/array/-private/enumerable"; * One concrete implementations of this class include ArrayProxy. */ interface MutableArray<T> extends EmberArray<T>, MutableEnumerable<T> { - /** - * __Required.__ You must implement this method to apply this mixin. - */ - replace(idx: number, amt: number, objects: T[]): this; - /** - * 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: Enumerable<T>): this; - /** - * Pop object from array or nil if none are left. Works just like `pop()` but - * it is KVO-compliant. - */ - popObject(): T; - /** - * Shift an object from start of array or nil if none are left. Works just - * like `shift()` but it is KVO-compliant. - */ - shiftObject(): T; - /** - * 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: Enumerable<T>): 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: EmberArray<T>): this; + /** + * __Required.__ You must implement this method to apply this mixin. + */ + replace(idx: number, amt: number, objects: T[]): this; + /** + * 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: Enumerable<T>): this; + /** + * Pop object from array or nil if none are left. Works just like `pop()` but + * it is KVO-compliant. + */ + popObject(): T; + /** + * Shift an object from start of array or nil if none are left. Works just + * like `shift()` but it is KVO-compliant. + */ + shiftObject(): T; + /** + * 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: Enumerable<T>): 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: EmberArray<T>): this; } -declare const MutableArray: Mixin<MutableArray<unknown>>; +declare const MutableArray: Mixin; export default MutableArray;
true
Other
emberjs
ember.js
bb0811dbf4928e251d897e2572d653680a46cdb1.json
Update preview type tests for array and mutable
types/preview/@ember/array/test/array-proxy.ts
@@ -11,16 +11,16 @@ proxy.set('content', A(['amoeba', 'paramecium'])); proxy.get('firstObject'); // 'amoeba' const overridden = ArrayProxy.create({ - content: A(pets), - objectAtContent(idx: number): string | undefined { - return this.get('content').objectAt(idx)?.toUpperCase(); - }, + content: A(pets), + objectAtContent(this: ArrayProxy<string>, idx: number): string | undefined { + return this.get('content').objectAt(idx)?.toUpperCase(); + }, }); overridden.get('firstObject'); // 'DOG' class MyNewProxy<T> extends ArrayProxy<T> { - isNew = true; + isNew = true; } const x = MyNewProxy.create({ content: A([1, 2, 3]) }) as MyNewProxy<number>; @@ -29,20 +29,20 @@ assertType<boolean>(x.isNew); // Custom EmberArray class MyArray<T> extends EmberObject.extend(EmberArray) { - constructor(content: ArrayLike<T>) { - super(); - this._content = content; - } + constructor(content: ArrayLike<T>) { + super(); + this._content = content; + } - _content: ArrayLike<T>; + _content: ArrayLike<T>; - get length() { - return this._content.length; - } + get length() { + return this._content.length; + } - objectAt(idx: number) { - return this._content[idx]; - } + objectAt(idx: number) { + return this._content[idx]; + } } const customArrayProxy = ArrayProxy.create({ content: new MyArray(pets) });
true
Other
emberjs
ember.js
9ca3053f1cc61b184c8f4de0886e7282bed34b03.json
Update preview type tests for arrays/array mixins
types/preview/@ember/array/-private/native-array.d.ts
@@ -13,11 +13,11 @@ type GlobalArray<T> = T[]; * at anytime by calling `Ember.NativeArray.apply(Array.prototype)`. */ interface NativeArray<T> extends GlobalArray<T>, MutableArray<T>, Observable { - /** - * __Required.__ You must implement this method to apply this mixin. - */ - length: number; + /** + * __Required.__ You must implement this method to apply this mixin. + */ + length: number; } -declare const NativeArray: Mixin<NativeArray<unknown>>; +declare const NativeArray: Mixin; export default NativeArray;
true
Other
emberjs
ember.js
9ca3053f1cc61b184c8f4de0886e7282bed34b03.json
Update preview type tests for arrays/array mixins
types/preview/@ember/array/index.d.ts
@@ -1,66 +1,57 @@ -// Type definitions for non-npm package @ember/array 4.0 -// Project: https://emberjs.com/api/ember/4.0/modules/@ember%2Farray -// Definitions by: Chris Krycho <https://github.com/chriskrycho> -// Dan Freeman <https://github.com/dfreeman> -// James C. Davis <https://github.com/jamescdavis> -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Minimum TypeScript Version: 4.4 - -import ComputedProperty from "@ember/object/computed"; -import Mixin from "@ember/object/mixin"; -import Enumerable from "@ember/array/-private/enumerable"; -import NativeArray from "@ember/array/-private/native-array"; +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<T> extends Enumerable<T> { - /** - * __Required.__ You must implement this method to apply this mixin. - */ - length: number | ComputedProperty<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`. - */ - // tslint:disable-next-line:array-type - objectsAt(indexes: number[]): Array<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): T[]; - /** - * 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; - /** - * Returns a special object that can be used to observe individual properties - * on the array. Just get an equivalent property on this object and it will - * return an enumerable that maps automatically to the named key on the - * member objects. - */ - '@each': ComputedProperty<T>; + /** + * __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`. + */ + // tslint:disable-next-line:array-type + objectsAt(indexes: number[]): Array<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): T[]; + /** + * 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; + /** + * Returns a special object that can be used to observe individual properties + * on the array. Just get an equivalent property on this object and it will + * return an enumerable that maps automatically to the named key on the + * member objects. + */ + '@each': T; } // Ember.Array rather than Array because the `array-type` lint rule doesn't realize the global is shadowed // tslint:disable-next-line:array-type -declare const Array: Mixin<Array<unknown>>; +declare const Array: Mixin; export default Array; /**
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/component/-private/class-names-support.d.ts
@@ -1,25 +1,25 @@ 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[]; + /** + * 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[]; } -declare const ClassNamesSupport: Mixin<ClassNamesSupport>; +declare const ClassNamesSupport: Mixin; export default ClassNamesSupport;
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/component/-private/view-mixin.d.ts
@@ -1,57 +1,57 @@ 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; + /** + * 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; } -declare const ViewMixin: Mixin<ViewMixin>; +declare const ViewMixin: Mixin; export default ViewMixin;
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/debug/container-debug-adapter.d.ts
@@ -5,7 +5,7 @@ import Resolver from 'ember-resolver'; * with tools that debug Ember such as the Ember Inspector for Chrome and Firefox. */ export default class ContainerDebugAdapter extends Object { - resolver: Resolver; - canCatalogEntriesByType(type: string): boolean; - catalogEntriesByType(type: string): string[]; + resolver: Resolver; + canCatalogEntriesByType(type: string): boolean; + catalogEntriesByType(type: string): string[]; }
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts
@@ -6,47 +6,47 @@ import Mixin from '@ember/object/mixin'; * registry functionality. */ interface RegistryProxyMixin extends Owner { - /** - * Given a fullName return the corresponding factory. - */ - resolveRegistration(fullName: string): unknown; - /** - * Unregister a factory. - */ - unregister(fullName: string): unknown; - /** - * Check if a factory is registered. - */ - hasRegistration(fullName: string): boolean; - /** - * Register an option for a particular factory. - */ - registerOption(fullName: string, optionName: string, options: {}): unknown; - /** - * Return a specific registered option for a particular factory. - */ - registeredOption(fullName: string, optionName: string): {}; - /** - * Register options for a particular factory. - */ - registerOptions(fullName: string, options: {}): unknown; - /** - * Return registered options for a particular factory. - */ - registeredOptions(fullName: string): {}; - /** - * Allow registering options for all factories of a type. - */ - registerOptionsForType(type: string, options: {}): unknown; - /** - * Return the registered options for all factories of a type. - */ - registeredOptionsForType(type: string): {}; - /** - * Define a dependency injection onto a specific factory or all factories - * of a type. - */ - inject(factoryNameOrType: string, property: string, injectionName: string): unknown; + /** + * Given a fullName return the corresponding factory. + */ + resolveRegistration(fullName: string): unknown; + /** + * Unregister a factory. + */ + unregister(fullName: string): unknown; + /** + * Check if a factory is registered. + */ + hasRegistration(fullName: string): boolean; + /** + * Register an option for a particular factory. + */ + registerOption(fullName: string, optionName: string, options: {}): unknown; + /** + * Return a specific registered option for a particular factory. + */ + registeredOption(fullName: string, optionName: string): {}; + /** + * Register options for a particular factory. + */ + registerOptions(fullName: string, options: {}): unknown; + /** + * Return registered options for a particular factory. + */ + registeredOptions(fullName: string): {}; + /** + * Allow registering options for all factories of a type. + */ + registerOptionsForType(type: string, options: {}): unknown; + /** + * Return the registered options for all factories of a type. + */ + registeredOptionsForType(type: string): {}; + /** + * Define a dependency injection onto a specific factory or all factories + * of a type. + */ + inject(factoryNameOrType: string, property: string, injectionName: string): unknown; } -declare const RegistryProxyMixin: Mixin<RegistryProxyMixin>; +declare const RegistryProxyMixin: Mixin; export default RegistryProxyMixin;
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/engine/test/engine.ts
@@ -1,39 +1,41 @@ import Engine from '@ember/engine'; import EmberObject from '@ember/object'; -const BaseEngine = Engine.extend({ - modulePrefix: 'my-engine', -}); +class BaseEngine extends Engine { + modulePrefix = 'my-engine'; +} -class Obj extends EmberObject.extend({ foo: 'bar' }) {} +class Obj extends EmberObject { + foo = 'bar'; +} BaseEngine.initializer({ - name: 'my-initializer', - initialize(engine) { - engine.register('foo:bar', Obj); - }, + name: 'my-initializer', + initialize(engine) { + engine.register('foo:bar', Obj); + }, }); BaseEngine.instanceInitializer({ - name: 'my-instance-initializer', - initialize(engine) { - (engine.lookup('foo:bar') as Obj).get('foo'); - }, + name: 'my-instance-initializer', + initialize(engine) { + (engine.lookup('foo:bar') as Obj).get('foo'); + }, }); const Engine1 = BaseEngine.create({ - rootElement: '#engine-one', - customEvents: { - paste: 'paste', - }, + rootElement: '#engine-one', + customEvents: { + paste: 'paste', + }, }); const Engine2 = BaseEngine.create({ - rootElement: '#engine-two', - customEvents: { - mouseenter: null, - mouseleave: null, - }, + rootElement: '#engine-two', + customEvents: { + mouseenter: null, + mouseleave: null, + }, }); const Engine3 = BaseEngine.create();
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/object/-private/action-handler.d.ts
@@ -1,7 +1,8 @@ +import { AnyFn } from 'ember/-private/type-utils'; import type Mixin from '../mixin'; interface ActionsHash { - [index: string]: (...params: any[]) => any; + [index: string]: AnyFn; } /** @@ -24,5 +25,5 @@ interface ActionHandler { */ actions: ActionsHash; } -declare const ActionHandler: Mixin<ActionHandler>; +declare const ActionHandler: Mixin; export default ActionHandler;
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/object/evented.d.ts
@@ -1,60 +1,43 @@ import Mixin from '@ember/object/mixin'; -import { AnyFn, EmberMethod, MethodNamesOf, MethodParams, MethodsOf } from 'ember/-private/type-utils'; +import { AnyFn, EmberMethod } from 'ember/-private/type-utils'; /** * This mixin allows for Ember objects to subscribe to and emit events. */ interface Evented { - /** - * Subscribes to a named event with given function. - */ - on<T>( - name: string, - target: T, - method: EmberMethod<T> - ): this; - on(name: string, method: EmberMethod<this>): this; - /** - * Subscribes a function to a named event and then cancels the subscription - * after the first time the event is triggered. It is good to use ``one`` when - * you only care about the first time an event has taken place. - */ - one<T>( - name: string, - target: T, - method: EmberMethod<T> - ): this; - one(name: string, method: EmberMethod<this>): this; - /** - * Triggers a named event for the object. Any additional arguments - * will be passed as parameters to the functions that are subscribed to the - * event. - */ - trigger(name: string, ...args: unknown[]): any; - /** - * Cancels subscription for given name, target, and method. - */ - off<T>( - name: string, - target: T, - method: EmberMethod<T> - ): this; - off(name: string, method: EmberMethod<this>): this; - /** - * Checks to see if object has any subscriptions for named event. - */ - has(name: string): boolean; + /** + * Subscribes to a named event with given function. + */ + on<T>(name: string, target: T, method: EmberMethod<T>): this; + on(name: string, method: EmberMethod<this>): this; + /** + * Subscribes a function to a named event and then cancels the subscription + * after the first time the event is triggered. It is good to use ``one`` when + * you only care about the first time an event has taken place. + */ + one<T>(name: string, target: T, method: EmberMethod<T>): this; + one(name: string, method: EmberMethod<this>): this; + /** + * Triggers a named event for the object. Any additional arguments + * will be passed as parameters to the functions that are subscribed to the + * event. + */ + trigger(name: string, ...args: unknown[]): any; + /** + * Cancels subscription for given name, target, and method. + */ + off<T>(name: string, target: T, method: EmberMethod<T>): this; + off(name: string, method: EmberMethod<this>): this; + /** + * Checks to see if object has any subscriptions for named event. + */ + has(name: string): boolean; } -declare const Evented: Mixin<Evented>; +declare const Evented: Mixin; export default Evented; /** * Define a property as a function that should be executed when * a specified event or events are triggered. */ -export function on<F extends AnyFn>( - ...args: [ - ...eventNames: string[], - func: F - ] -): F; +export function on<F extends AnyFn>(...args: [...eventNames: string[], func: F]): F;
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/object/observable.d.ts
@@ -5,7 +5,7 @@ import CoreObject from './core'; /** * This mixin provides properties and property observing functionality, core features of the Ember object model. */ -interface Observable { +interface Observable extends CoreObject { /** * Retrieves the value of a property from the object. */ @@ -79,5 +79,5 @@ interface Observable { */ cacheFor<K extends keyof this>(key: K): this[K] | undefined; } -declare const Observable: Mixin<Observable, CoreObject>; +declare const Observable: Mixin; export default Observable;
true
Other
emberjs
ember.js
a5e36423469108db1b49a9a04d2a752182904054.json
Update preview type tests for many Mixin types
types/preview/@ember/object/promise-proxy-mixin.d.ts
@@ -1,35 +1,35 @@ -import Mixin from "@ember/object/mixin"; -import RSVP from "rsvp"; +import Mixin from '@ember/object/mixin'; +import RSVP from 'rsvp'; /** * A low level mixin making ObjectProxy promise-aware. */ interface PromiseProxyMixin<T> extends RSVP.Promise<T> { - /** - * If the proxied promise is rejected this will contain the reason - * provided. - */ - reason: unknown; - /** - * Once the proxied promise has settled this will become `false`. - */ - isPending: boolean; - /** - * Once the proxied promise has settled this will become `true`. - */ - isSettled: boolean; - /** - * Will become `true` if the proxied promise is rejected. - */ - isRejected: boolean; - /** - * Will become `true` if the proxied promise is fulfilled. - */ - isFulfilled: boolean; - /** - * The promise whose fulfillment value is being proxied by this object. - */ - promise: RSVP.Promise<T>; + /** + * If the proxied promise is rejected this will contain the reason + * provided. + */ + reason: unknown; + /** + * Once the proxied promise has settled this will become `false`. + */ + isPending: boolean; + /** + * Once the proxied promise has settled this will become `true`. + */ + isSettled: boolean; + /** + * Will become `true` if the proxied promise is rejected. + */ + isRejected: boolean; + /** + * Will become `true` if the proxied promise is fulfilled. + */ + isFulfilled: boolean; + /** + * The promise whose fulfillment value is being proxied by this object. + */ + promise: RSVP.Promise<T>; } -declare const PromiseProxyMixin: Mixin<PromiseProxyMixin<any>>; +declare const PromiseProxyMixin: Mixin; export default PromiseProxyMixin;
true
Other
emberjs
ember.js
920901efa8a9734fdbdf26192ea7cf288d803d2e.json
Update preview type tests for EmberObject.reopen()
types/preview/@ember/object/test/reopen.ts
@@ -1,75 +1,79 @@ -import { assertType } from './lib/assert'; import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; +import { expectTypeOf } from 'expect-type'; -type Person = typeof Person.prototype; -const Person = EmberObject.extend({ - name: '', - sayHello() { - alert(`Hello. My name is ${this.get('name')}`); - }, -}); +class Person extends EmberObject { + name = ''; + + sayHello() { + alert(`Hello. My name is ${this.get('name')}`); + } +} -assertType<Person>(Person.reopen()); +expectTypeOf(Person.reopen()).toMatchTypeOf<typeof Person>(); -assertType<string>(Person.create().name); -// tslint:disable-next-line no-void-expression -assertType<void>(Person.create().sayHello()); +expectTypeOf(Person.create().name).toEqualTypeOf<string>(); +expectTypeOf(Person.create().sayHello()).toBeVoid(); +// Here, a basic check that `reopenClass` *works*, but we intentionally do not +// provide types for how it changes the original class (as spec'd in RFC 0800). const Person2 = Person.reopenClass({ - species: 'Homo sapiens', + species: 'Homo sapiens', - createPerson(name: string): Person { - return Person.create({ name }); - }, + createPerson(name: string): Person { + return Person.create({ name }); + }, }); -assertType<string>(Person2.create().name); -// tslint:disable-next-line no-void-expression -assertType<void>(Person2.create().sayHello()); -assertType<string>(Person2.species); +// The original class types are carried along +expectTypeOf(Person2.create().name).toEqualTypeOf<string>(); +expectTypeOf(Person2.create().sayHello()).toBeVoid(); +// But we aren't trying to merge in new classes anymore. +// @ts-expect-error +Person2.species; const tom = Person2.create({ - name: 'Tom Dale', + name: 'Tom Dale', }); // @ts-expect-error const badTom = Person2.create({ name: 99 }); +// @ts-expect-error const yehuda = Person2.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" +// @ts-expect-error alert(Person2.species); // "Homo sapiens" +// The same goes for `.reopen()`: it will "work" in a bare minimum sense, but it +// will not try to change the types. const Person3 = Person2.reopen({ - goodbyeMessage: 'goodbye', + goodbyeMessage: 'goodbye', - sayGoodbye() { - alert(`${this.get('goodbyeMessage')}, ${this.get('name')}`); - }, + sayGoodbye(this: Person) { + alert(`${this.get('goodbyeMessage')}, ${this.get('name')}`); + }, }); const person3 = Person3.create(); person3.get('name'); person3.get('goodbyeMessage'); person3.sayHello(); +// @ts-expect-error person3.sayGoodbye(); interface AutoResizeMixin { - resizable: true; + resizable: true; } -declare const AutoResizeMixin: Mixin<AutoResizeMixin>; - -const ResizableTextArea = EmberObject.reopen(AutoResizeMixin, { - scaling: 1.0, -}); -const text = ResizableTextArea.create(); -// TODO fix upstream -// assertType<boolean>(text.resizable); -assertType<number>(text.scaling); +const AutoResizeMixin = Mixin.create({ resizable: true }); +// And the same here. const Reopened = EmberObject.reopenClass({ a: 1 }, { b: 2 }, { c: 3 }); -assertType<number>(Reopened.a); -assertType<number>(Reopened.b); -assertType<number>(Reopened.c); +// @ts-expect-error +Reopened.a; +// @ts-expect-error +Reopened.b; +// @ts-expect-error +Reopened.c;
true
Other
emberjs
ember.js
920901efa8a9734fdbdf26192ea7cf288d803d2e.json
Update preview type tests for EmberObject.reopen()
types/preview/ember/test/reopen.ts
@@ -1,6 +1,5 @@ import Ember from 'ember'; import { expectTypeOf } from 'expect-type'; -import { assertType } from './lib/assert'; class Person extends Ember.Object { name = '';
true
Other
emberjs
ember.js
81655aed415b191188bb9a960fd4ec58ad74c7db.json
Update preview type tests for EmberObject.create()
types/preview/@ember/object/test/create.ts
@@ -1,54 +1,57 @@ -import { assertType } from './lib/assert'; import EmberObject, { computed } from '@ember/object'; -import ComputedProperty from '@ember/object/computed'; +import { expectTypeOf } from 'expect-type'; /** * Zero-argument case */ const o = EmberObject.create(); // create returns an object -assertType<object>(o); -// object returned by create type-checks as an instance of Ember.Object -assertType<boolean>(o.isDestroyed); // from instance -assertType<boolean>(o.isDestroying); // from instance -assertType<(key: keyof EmberObject) => any>(o.get); // from prototype +expectTypeOf(o).toBeObject(); +// object returned by create type-checks as an instance of EmberObject +expectTypeOf(o.isDestroyed).toBeBoolean(); +expectTypeOf(o.isDestroying).toBeBoolean(); +expectTypeOf(o.get).toMatchTypeOf<<K extends keyof EmberObject>(key: K) => EmberObject[K]>(); /** * One-argument case */ -const o1 = EmberObject.create({ x: 9, y: 'hello', z: false }); -assertType<number>(o1.x); -assertType<string>(o1.y); -o1.y; // $ExpectType string -o1.z; // $ExpectType boolean +class O1 extends EmberObject { + declare x: number; + declare y: string; + declare z: boolean; +} -const obj = EmberObject.create({ a: 1 }, { b: 2 }, { c: 3 }); -assertType<number>(obj.b); -assertType<number>(obj.a); -assertType<number>(obj.c); +const o1 = O1.create({ x: 9, y: 'hello', z: false }); +expectTypeOf(o1.x).toBeNumber(); +expectTypeOf(o1.y).toBeString(); +expectTypeOf(o1.z).toBeBoolean(); -export class Person extends EmberObject { - fullName = computed('firstName', 'lastName', function () { - return [this.firstName + this.lastName].join(' '); - }); - declare firstName: string; - declare lastName: string; - declare age: number; +class O2 extends EmberObject { + declare a: number; + declare b: number; + declare c: number; } -const p = new Person(); - -assertType<string>(p.firstName); -assertType<ComputedProperty<string>>(p.fullName); -assertType<string>(p.get('fullName')); +const obj = O2.create({ a: 1 }, { b: 2 }, { c: 3 }); +expectTypeOf(obj.b).toBeNumber(); +expectTypeOf(obj.a).toBeNumber(); +expectTypeOf(obj.c).toBeNumber(); -const p2 = Person.create({ firstName: 'string' }); -const p2b = Person.create({}, { firstName: 'string' }); -const p2c = Person.create({}, {}, { firstName: 'string' }); +export class Person extends EmberObject { + declare firstName: string; + declare lastName: string; + declare age: number; + + @computed('firstName', 'lastName') + get fullName() { + return [this.firstName + this.lastName].join(' '); + } +} +const p = Person.create(); -export class PersonWithNumberName extends Person.extend({ - fullName: 6, -}) {} +expectTypeOf(p.firstName).toBeString(); +expectTypeOf(p.fullName).toBeString(); +expectTypeOf(p.get('fullName')).toBeString(); -const p4 = new PersonWithNumberName(); -assertType<string>(p4.firstName); -assertType<number>(p4.fullName); +Person.create({ firstName: 'string' }); +Person.create({}, { firstName: 'string' }); +Person.create({}, {}, { firstName: 'string' });
true
Other
emberjs
ember.js
81655aed415b191188bb9a960fd4ec58ad74c7db.json
Update preview type tests for EmberObject.create()
types/preview/ember/test/create.ts
@@ -1,55 +1,57 @@ import Ember from 'ember'; -import { assertType } from './lib/assert'; -import { UnwrapComputedPropertyGetter } from "@ember/object/-private/types"; +import { expectTypeOf } from 'expect-type'; /** * Zero-argument case */ const o = Ember.Object.create(); // create returns an object -assertType<object>(o); +expectTypeOf(o).toBeObject(); // object returned by create type-checks as an instance of Ember.Object -assertType<boolean>(o.isDestroyed); // from instance -assertType<boolean>(o.isDestroying); // from instance -assertType<<K extends keyof Ember.Object>(key: K) => UnwrapComputedPropertyGetter<Ember.Object[K]>>(o.get); // from prototype +expectTypeOf(o.isDestroyed).toBeBoolean(); +expectTypeOf(o.isDestroying).toBeBoolean(); +expectTypeOf(o.get).toMatchTypeOf<<K extends keyof Ember.Object>(key: K) => Ember.Object[K]>(); /** * One-argument case */ -const o1 = Ember.Object.create({ x: 9, y: 'hello', z: false }); -assertType<number>(o1.x); -assertType<string>(o1.y); -o1.y; // $ExpectType string -o1.z; // $ExpectType boolean - -const obj = Ember.Object.create({ a: 1 }, { b: 2 }, { c: 3 }); -assertType<number>(obj.b); -assertType<number>(obj.a); -assertType<number>(obj.c); - -export class Person extends Ember.Object.extend({ - fullName: Ember.computed('firstName', 'lastName', function () { - return [this.firstName + this.lastName].join(' '); - }), -}) { - declare firstName: string; - declare lastName: string; - declare age: number; +class O1 extends Ember.Object { + declare x: number; + declare y: string; + declare z: boolean; } -const p = new Person(); -assertType<string>(p.firstName); -assertType<Ember.ComputedProperty<string>>(p.fullName); -assertType<string>(p.get('fullName')); +const o1 = O1.create({ x: 9, y: 'hello', z: false }); +expectTypeOf(o1.x).toBeNumber(); +expectTypeOf(o1.y).toBeString(); +expectTypeOf(o1.z).toBeBoolean(); -const p2 = Person.create({ firstName: 'string' }); -const p2b = Person.create({}, { firstName: 'string' }); -const p2c = Person.create({}, {}, { firstName: 'string' }); +class O2 extends Ember.Object { + declare a: number; + declare b: number; + declare c: number; +} +const obj = O2.create({ a: 1 }, { b: 2 }, { c: 3 }); +expectTypeOf(obj.b).toBeNumber(); +expectTypeOf(obj.a).toBeNumber(); +expectTypeOf(obj.c).toBeNumber(); + +export class Person extends Ember.Object { + declare firstName: string; + declare lastName: string; + declare age: number; + + @Ember.computed('firstName', 'lastName') + get fullName() { + return [this.firstName + this.lastName].join(' '); + } +} +const p = Person.create(); -export class PersonWithNumberName extends Person.extend({ - fullName: 6, -}) {} +expectTypeOf(p.firstName).toBeString(); +expectTypeOf(p.fullName).toBeString(); +expectTypeOf(p.get('fullName')).toBeString(); -const p4 = new PersonWithNumberName(); -assertType<string>(p4.firstName); -assertType<number>(p4.fullName); +Person.create({ firstName: 'string' }); +Person.create({}, { firstName: 'string' }); +Person.create({}, {}, { firstName: 'string' });
true
Other
emberjs
ember.js
71e1e3f5d293f44a5f7e481e02770f4386f88f6d.json
Update preview type tests for Ember.DataAdapter
types/preview/ember/test/data-adapter.ts
@@ -1,52 +1,53 @@ import Ember from 'ember'; +import { expectTypeOf } from 'expect-type'; const da = Ember.DataAdapter.create(); const filters = da.getFilters(); -filters.includes({ name: 'foo', desc: 'bar' }); // $ExpectType boolean +expectTypeOf(filters.includes({ name: 'foo', desc: 'bar' })).toBeBoolean(); // @ts-expect-error filters.includes({}); -filters[0].name; // $ExpectType string -filters[0].desc; // $ExpectType string +expectTypeOf(filters[0]?.name).toEqualTypeOf<string | undefined>(); +expectTypeOf(filters[0]?.desc).toEqualTypeOf<string | undefined>(); // $ExpectType () => void da.watchModelTypes( - function added(wrappedTypes) { - wrappedTypes; - wrappedTypes[0].release; // $ExpectType () => void - wrappedTypes[0].type.columns[0].desc; // $ExpectType string - wrappedTypes[0].type.columns[0].name; // $ExpectType string - wrappedTypes[0].type.count; // $ExpectType number - wrappedTypes[0].type.name; // $ExpectType string - }, - function updated(wrappedTypes) { - wrappedTypes; - wrappedTypes[0].release; // $ExpectType () => void - wrappedTypes[0].type.columns[0].desc; // $ExpectType string - wrappedTypes[0].type.columns[0].name; // $ExpectType string - wrappedTypes[0].type.count; // $ExpectType number - wrappedTypes[0].type.name; // $ExpectType string - }, + function added(wrappedTypes) { + wrappedTypes; + expectTypeOf(wrappedTypes[0]?.release).toEqualTypeOf<(() => void) | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.columns[0]?.desc).toEqualTypeOf<string | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.columns[0]?.name).toEqualTypeOf<string | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.count).toEqualTypeOf<number | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.name).toEqualTypeOf<string | undefined>(); + }, + function updated(wrappedTypes) { + wrappedTypes; + expectTypeOf(wrappedTypes[0]?.release).toEqualTypeOf<(() => void) | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.columns[0]?.desc).toEqualTypeOf<string | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.columns[0]?.name).toEqualTypeOf<string | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.count).toEqualTypeOf<number | undefined>(); + expectTypeOf(wrappedTypes[0]?.type.name).toEqualTypeOf<string | undefined>(); + } ); // @ts-expect-error da.watchModelTypes(() => {}); // $ExpectType () => void da.watchRecords( - 'house', - function added(records) { - records[0].object; // $ExpectType object - records[0].columnValues; // $ExpectType object - }, - function updated(records) { - records[0].object; // $ExpectType object - records[0].columnValues; // $ExpectType object - }, - function removed(idx, count) { - idx; // $ExpectType number - count; // $ExpectType number - }, + 'house', + function added(records) { + expectTypeOf(records[0]?.object).toEqualTypeOf<object | undefined>(); + expectTypeOf(records[0]?.columnValues).toEqualTypeOf<object | undefined>(); + }, + function updated(records) { + expectTypeOf(records[0]?.object).toEqualTypeOf<object | undefined>(); + expectTypeOf(records[0]?.columnValues).toEqualTypeOf<object | undefined>(); + }, + function removed(idx, count) { + idx; // $ExpectType number + count; // $ExpectType number + } ); // @ts-expect-error da.watchRecords(() => {});
false
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/application/namespace.ts
@@ -1,5 +1,5 @@ /** -@module @ember/application +@module @ember/application/namespace */ import {
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/array/proxy.ts
@@ -1,5 +1,5 @@ /** -@module @ember/array +@module @ember/array/proxy */ import {
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/debug/container-debug-adapter.ts
@@ -9,7 +9,7 @@ import type { Resolver } from '@ember/-internals/container'; import Namespace from '@ember/application/namespace'; /** -@module @ember/debug +@module @ember/debug/container-debug-adapter */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/debug/data-adapter.ts
@@ -11,6 +11,10 @@ import type { Cache } from '@glimmer/validator'; import { consumeTag, createCache, getValue, tagFor, untrack } from '@glimmer/validator'; import type ContainerDebugAdapter from '@ember/debug/container-debug-adapter'; +/** +@module @ember/debug/data-adapter +*/ + type RecordColor = 'black' | 'red' | 'blue' | 'green'; type WrappedType<N extends string = string> = { @@ -151,10 +155,6 @@ class TypeWatcher { } } -/** -@module @ember/debug -*/ - /** The `DataAdapter` helps a data persistence library interface with tools that debug Ember such
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/object/core.ts
@@ -1,5 +1,5 @@ /** - @module @ember/object + @module @ember/object/core */ import { getFactoryFor, setFactoryFor } from '@ember/-internals/container';
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/object/evented.ts
@@ -4,7 +4,7 @@ import Mixin from '@ember/object/mixin'; export { on } from '@ember/-internals/metal'; /** -@module @ember/object +@module @ember/object/evented */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/object/mixin.ts
@@ -1,5 +1,5 @@ /** -@module @ember/object +@module @ember/object/mixin */ import { INIT_FACTORY } from '@ember/-internals/container'; import type { Meta } from '@ember/-internals/meta';
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/object/observable.ts
@@ -1,5 +1,5 @@ /** -@module @ember/object +@module @ember/object/observable */ import { peekMeta } from '@ember/-internals/meta';
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/object/promise-proxy-mixin.ts
@@ -6,7 +6,7 @@ import type RSVP from 'rsvp'; import type CoreObject from '@ember/object/core'; /** - @module @ember/object + @module @ember/object/promise-proxy-mixin */ function tap<T>(proxy: PromiseProxyMixin<T>, promise: RSVP.Promise<T>) {
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/object/proxy.ts
@@ -1,3 +1,7 @@ +/** +@module @ember/object/proxy +*/ + import { FrameworkObject } from '@ember/object/-internals'; import { _ProxyMixin } from '@ember/-internals/runtime';
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/auto-location.ts
@@ -15,7 +15,7 @@ import { } from './lib/location-utils'; /** -@module @ember/routing +@module @ember/routing/auto-location */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/hash-location.ts
@@ -4,7 +4,7 @@ import type { ILocation as EmberLocation, UpdateCallback } from '@ember/routing/ import { getHash } from './lib/location-utils'; /** -@module @ember/routing +@module @ember/routing/hash-location */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/history-location.ts
@@ -3,7 +3,7 @@ import type { ILocation as EmberLocation, UpdateCallback } from '@ember/routing/ import { getHash } from './lib/location-utils'; /** -@module @ember/routing +@module @ember/routing/history-location */ let popstateFired = false;
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/location.ts
@@ -15,7 +15,7 @@ export interface ILocation { export type UpdateCallback = (url: string) => void; /** -@module @ember/routing +@module @ember/routing/location */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/none-location.ts
@@ -3,7 +3,7 @@ import { assert } from '@ember/debug'; import type { ILocation as EmberLocation, UpdateCallback } from '@ember/routing/location'; /** -@module @ember/routing +@module @ember/routing/none-location */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/route.ts
@@ -70,7 +70,7 @@ export const ROUTE_CONNECTIONS = new WeakMap(); const RENDER = Symbol('render'); /** -@module @ember/routing +@module @ember/routing/route */ /**
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/router-service.ts
@@ -1,3 +1,6 @@ +/** + * @module @ember/routing/router-service + */ import { getOwner } from '@ember/-internals/owner'; import Evented from '@ember/object/evented'; import { assert } from '@ember/debug';
true
Other
emberjs
ember.js
63e01acb5b03ed98d0fe0d27e4581edde72697ba.json
Fix YUIDoc module names
packages/@ember/routing/router.ts
@@ -46,7 +46,7 @@ import type { QueryParams } from 'route-recognizer'; import type { AnyFn, MethodNamesOf, OmitFirst } from '@ember/-internals/utils/types'; /** -@module @ember/routing +@module @ember/routing/router */ function defaultDidTransition<R extends Route>(
true
Other
emberjs
ember.js
6d5fabe48d226a679324ad2b788666179a6ad0e6.json
Move RouterState into @ember/routing
packages/@ember/-internals/glimmer/lib/components/link-to.ts
@@ -1,6 +1,5 @@ import type Route from '@ember/routing/route'; -import type { RouterState } from '@ember/-internals/routing'; -import type { RoutingService } from '@ember/routing/internals'; +import type { RouterState, RoutingService } from '@ember/routing/internals'; import { isSimpleClick } from '@ember/-internals/views'; import { assert, debugFreeze, inspect, warn } from '@ember/debug'; import { getEngineParent } from '@ember/engine';
true
Other
emberjs
ember.js
6d5fabe48d226a679324ad2b788666179a6ad0e6.json
Move RouterState into @ember/routing
packages/@ember/-internals/routing/index.ts
@@ -16,7 +16,6 @@ export { default as RouterDSL, DSLCallback } from './lib/system/dsl'; export { EngineRouteInfo } from './lib/system/engines'; export { default as QueryParams } from './lib/system/query_params'; export { RouteInfo, RouteInfoWithAttributes } from './lib/system/route-info'; -export { default as RouterState } from './lib/system/router_state'; export { default as BucketCache } from './lib/system/cache'; export { calculateCacheKey,
true
Other
emberjs
ember.js
6d5fabe48d226a679324ad2b788666179a6ad0e6.json
Move RouterState into @ember/routing
packages/@ember/routing/internals.ts
@@ -1 +1,2 @@ +export { default as RouterState } from './lib/router_state'; export { default as RoutingService } from './lib/routing-service';
true
Other
emberjs
ember.js
6d5fabe48d226a679324ad2b788666179a6ad0e6.json
Move RouterState into @ember/routing
packages/@ember/routing/lib/router_state.ts
@@ -1,6 +1,6 @@ import type { ModelFor, TransitionState } from 'router_js'; import type Router from 'router_js'; -import { shallowEqual } from '../utils'; +import { shallowEqual } from '@ember/-internals/routing'; import type Route from '@ember/routing/route'; import type EmberRouter from '@ember/routing/router';
true
Other
emberjs
ember.js
6d5fabe48d226a679324ad2b788666179a6ad0e6.json
Move RouterState into @ember/routing
packages/@ember/routing/lib/routing-service.ts
@@ -9,7 +9,7 @@ import Service from '@ember/service'; import type { ModelFor } from 'router_js'; import type Route from '@ember/routing/route'; import EmberRouter from '@ember/routing/router'; -import type { RouterState } from '@ember/-internals/routing'; +import type { RouterState } from '@ember/routing/internals'; import { ROUTER } from '@ember/routing/router-service'; /**
true
Other
emberjs
ember.js
6d5fabe48d226a679324ad2b788666179a6ad0e6.json
Move RouterState into @ember/routing
packages/@ember/routing/router.ts
@@ -6,12 +6,12 @@ import { getOwner } from '@ember/-internals/owner'; import { BucketCache, RouterDSL as DSL, - RouterState, calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL, } from '@ember/-internals/routing'; +import { RouterState } from '@ember/routing/internals'; import type { DSLCallback, EngineRouteInfo,
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/@ember/-internals/glimmer/lib/components/link-to.ts
@@ -1,5 +1,6 @@ import type Route from '@ember/routing/route'; -import type { RouterState, RoutingService } from '@ember/-internals/routing'; +import type { RouterState } from '@ember/-internals/routing'; +import type { RoutingService } from '@ember/routing/internals'; import { isSimpleClick } from '@ember/-internals/views'; import { assert, debugFreeze, inspect, warn } from '@ember/debug'; import { getEngineParent } from '@ember/engine';
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/@ember/-internals/routing/index.ts
@@ -16,7 +16,6 @@ export { default as RouterDSL, DSLCallback } from './lib/system/dsl'; export { EngineRouteInfo } from './lib/system/engines'; export { default as QueryParams } from './lib/system/query_params'; export { RouteInfo, RouteInfoWithAttributes } from './lib/system/route-info'; -export { default as RoutingService } from './lib/services/routing'; export { default as RouterState } from './lib/system/router_state'; export { default as BucketCache } from './lib/system/cache'; export {
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/@ember/engine/index.ts
@@ -11,7 +11,7 @@ import ContainerDebugAdapter from '@ember/debug/container-debug-adapter'; import { get, set } from '@ember/object'; import type { EngineInstanceOptions } from '@ember/engine/instance'; import EngineInstance from '@ember/engine/instance'; -import { RoutingService } from '@ember/-internals/routing'; +import { RoutingService } from '@ember/routing/internals'; import { ComponentLookup } from '@ember/-internals/views'; import { setupEngineRegistry } from '@ember/-internals/glimmer'; import { RegistryProxyMixin } from '@ember/-internals/runtime';
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/@ember/routing/internals.ts
@@ -0,0 +1 @@ +export { default as RoutingService } from './lib/routing-service';
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/@ember/routing/lib/routing-service.ts
@@ -9,7 +9,7 @@ import Service from '@ember/service'; import type { ModelFor } from 'router_js'; import type Route from '@ember/routing/route'; import EmberRouter from '@ember/routing/router'; -import type RouterState from '../system/router_state'; +import type { RouterState } from '@ember/-internals/routing'; import { ROUTER } from '@ember/routing/router-service'; /**
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/ember-testing/lib/helpers/current_path.ts
@@ -2,7 +2,7 @@ @module ember */ import { get } from '@ember/object'; -import { RoutingService } from '@ember/-internals/routing'; +import { RoutingService } from '@ember/routing/internals'; import type Application from '@ember/application'; import { assert } from '@ember/debug';
true
Other
emberjs
ember.js
c91bd15d61a42feff693444ea250cbf8750f5a1d.json
Move RoutingService into @ember/routing
packages/ember-testing/lib/helpers/current_route_name.ts
@@ -2,7 +2,7 @@ @module ember */ import { get } from '@ember/object'; -import { RoutingService } from '@ember/-internals/routing'; +import { RoutingService } from '@ember/routing/internals'; import type Application from '@ember/application'; import { assert } from '@ember/debug'; /**
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/-internals/container/index.ts
@@ -5,5 +5,5 @@ The public API, specified on the application namespace should be considered the @private */ -export { default as Registry, privatize } from './lib/registry'; +export { default as Registry, Resolver, ResolverClass, privatize } from './lib/registry'; export { default as Container, getFactoryFor, setFactoryFor, INIT_FACTORY } from './lib/container';
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/-internals/glimmer/index.ts
@@ -316,7 +316,7 @@ export { DOMChanges, NodeDOMTreeConstruction, DOMTreeConstruction } from './lib/ // TODO just test these through public API // a lot of these are testing how a problem was solved // rather than the problem was solved -export { default as OutletView } from './lib/views/outlet'; +export { default as OutletView, BootEnvironment } from './lib/views/outlet'; export { OutletState } from './lib/utils/outlet'; export { componentCapabilities,
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/application/instance.ts
@@ -8,7 +8,7 @@ import EngineInstance from '@ember/engine/instance'; import type { BootOptions } from '@ember/engine/instance'; import type Application from '@ember/application'; import { renderSettled } from '@ember/-internals/glimmer'; -import type { BootEnvironment } from '@ember/-internals/glimmer/lib/views/outlet'; +import type { BootEnvironment } from '@ember/-internals/glimmer'; import { assert } from '@ember/debug'; import Router from '@ember/routing/router'; import type { ViewMixin } from '@ember/-internals/views';
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/debug/container-debug-adapter.ts
@@ -5,7 +5,7 @@ import { A as emberA } from '@ember/array'; import { typeOf } from '@ember/-internals/runtime'; import type { Owner } from '@ember/-internals/owner'; import { getOwner } from '@ember/-internals/owner'; -import type { Resolver } from '@ember/-internals/container/lib/registry'; +import type { Resolver } from '@ember/-internals/container'; import Namespace from '@ember/application/namespace'; /**
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/engine/index.ts
@@ -4,6 +4,7 @@ import { canInvoke } from '@ember/-internals/utils'; import Controller from '@ember/controller'; import Namespace from '@ember/application/namespace'; import { Registry } from '@ember/-internals/container'; +import type { ResolverClass } from '@ember/-internals/container'; import DAG from 'dag-map'; import { assert } from '@ember/debug'; import ContainerDebugAdapter from '@ember/debug/container-debug-adapter'; @@ -13,8 +14,7 @@ import EngineInstance from '@ember/engine/instance'; import { RoutingService } from '@ember/-internals/routing'; import { ComponentLookup } from '@ember/-internals/views'; import { setupEngineRegistry } from '@ember/-internals/glimmer'; -import RegistryProxyMixin from '@ember/-internals/runtime/lib/mixins/registry_proxy'; -import type { ResolverClass } from '@ember/-internals/container/lib/registry'; +import { RegistryProxyMixin } from '@ember/-internals/runtime'; function props(obj: object) { let properties = [];
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/engine/instance.ts
@@ -9,12 +9,11 @@ import EmberError from '@ember/error'; import { Registry, privatize as P } from '@ember/-internals/container'; import { guidFor } from '@ember/-internals/utils'; import { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-parent'; -import RegistryProxyMixin from '@ember/-internals/runtime/lib/mixins/registry_proxy'; -import ContainerProxyMixin from '@ember/-internals/runtime/lib/mixins/container_proxy'; +import { ContainerProxyMixin, RegistryProxyMixin } from '@ember/-internals/runtime'; import { isFactory } from '@ember/-internals/owner'; import Engine from '@ember/engine'; import type Application from '@ember/application'; -import type { BootEnvironment } from '@ember/-internals/glimmer/lib/views/outlet'; +import type { BootEnvironment } from '@ember/-internals/glimmer'; import type { SimpleElement } from '@simple-dom/interface'; const CEngine = Engine;
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/@ember/object/compat.ts
@@ -5,7 +5,7 @@ import { isElementDescriptor, setClassicDecorator, } from '@ember/-internals/metal'; -import type { ElementDescriptor } from '@ember/-internals/metal/lib/decorator'; +import type { ElementDescriptor } from '@ember/-internals/metal'; import { assert } from '@ember/debug'; import type { UpdatableTag } from '@glimmer/validator'; import { consumeTag, tagFor, track, updateTag } from '@glimmer/validator';
true
Other
emberjs
ember.js
77f4722d01d70c82d4088ab616ceda650a77c582.json
Simplify internals imports
packages/internal-test-helpers/lib/test-resolver.ts
@@ -1,6 +1,6 @@ import { compile } from 'ember-template-compiler'; -import type { Resolver as IResolver } from '@ember/-internals/container/lib/registry'; +import type { Resolver as IResolver } from '@ember/-internals/container'; import type { Factory } from '@ember/-internals/owner'; const DELIMITER = '%';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/@ember/-internals/glimmer/lib/views/outlet.ts
@@ -1,6 +1,6 @@ import type { Owner } from '@ember/-internals/owner'; import { getOwner } from '@ember/-internals/owner'; -import type { BootOptions } from '@ember/application/instance'; +import type { BootOptions } from '@ember/engine/instance'; import { assert } from '@ember/debug'; import { schedule } from '@ember/runloop'; import type { Template } from '@glimmer/interfaces';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/@ember/application/index.ts
@@ -22,9 +22,9 @@ import { NoneLocation, BucketCache, } from '@ember/-internals/routing'; -import type { BootOptions } from '@ember/application/instance'; import ApplicationInstance from '@ember/application/instance'; import Engine, { buildInitializerMethod } from '@ember/engine'; +import type { BootOptions } from '@ember/engine/instance'; import type { Container, Registry } from '@ember/-internals/container'; import { privatize as P } from '@ember/-internals/container'; import { setupApplicationRegistry } from '@ember/-internals/glimmer';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/@ember/application/instance.ts
@@ -5,6 +5,7 @@ import { get, set } from '@ember/-internals/metal'; import * as environment from '@ember/-internals/browser-environment'; import EngineInstance from '@ember/engine/instance'; +import type { BootOptions } from '@ember/engine/instance'; import type Application from '@ember/application'; import { renderSettled } from '@ember/-internals/glimmer'; import type { BootEnvironment } from '@ember/-internals/glimmer/lib/views/outlet'; @@ -15,17 +16,6 @@ import { EventDispatcher } from '@ember/-internals/views'; import type { Registry } from '@ember/-internals/container'; import type { SimpleElement } from '@simple-dom/interface'; -export interface BootOptions { - isBrowser?: boolean; - shouldRender?: boolean; - document?: Document | null; - rootElement?: string | SimpleElement | null; - location?: string | null; - // Private? - isInteractive?: boolean; - _renderMode?: string; -} - /** The `ApplicationInstance` encapsulates all of the stateful aspects of a running `Application`.
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/@ember/application/type-tests/instance.test.ts
@@ -1,8 +1,8 @@ import type { Factory, Owner } from '@ember/-internals/owner'; +import type EngineInstance from '@ember/engine/instance'; +import type { BootOptions } from '@ember/engine/instance'; import Application from '@ember/application'; -import type { BootOptions } from '@ember/application/instance'; import type ApplicationInstance from '@ember/application/instance'; -import type EngineInstance from '@ember/engine/instance'; import EmberObject from '@ember/object'; import { expectTypeOf } from 'expect-type';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/@ember/engine/instance.ts
@@ -11,13 +11,24 @@ import { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-pa import RegistryProxyMixin from '@ember/-internals/runtime/lib/mixins/registry_proxy'; import ContainerProxyMixin from '@ember/-internals/runtime/lib/mixins/container_proxy'; import { isFactory } from '@ember/-internals/owner'; -import Engine from '.'; +import Engine from '@ember/engine'; import type Application from '@ember/application'; -import type { BootOptions } from '@ember/application/instance'; import type { BootEnvironment } from '@ember/-internals/glimmer/lib/views/outlet'; +import type { SimpleElement } from '@simple-dom/interface'; const CEngine = Engine; +export interface BootOptions { + isBrowser?: boolean; + shouldRender?: boolean; + document?: Document | null; + rootElement?: string | SimpleElement | null; + location?: string | null; + // Private? + isInteractive?: boolean; + _renderMode?: string; +} + export interface EngineInstanceOptions { mountPoint?: string; routable?: boolean;
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/internal-test-helpers/lib/test-cases/abstract-application.ts
@@ -3,8 +3,8 @@ import { compile } from 'ember-template-compiler'; import { ENV } from '@ember/-internals/environment'; import AbstractTestCase from './abstract'; import { runDestroy, runTask, runLoopSettled } from '../run'; +import type { BootOptions } from '@ember/engine/instance'; import type Application from '@ember/application'; -import type { BootOptions } from '@ember/application/instance'; import type ApplicationInstance from '@ember/application/instance'; import type Router from '@ember/routing/router';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/internal-test-helpers/lib/test-cases/query-param.ts
@@ -1,4 +1,4 @@ -import type { BootOptions } from '@ember/application/instance'; +import type { BootOptions } from '@ember/engine/instance'; import Controller from '@ember/controller'; import type EmberObject from '@ember/object'; import { NoneLocation } from '@ember/-internals/routing';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/internal-test-helpers/lib/test-cases/rendering.ts
@@ -10,8 +10,7 @@ import AbstractTestCase from './abstract'; import buildOwner from '../build-owner'; import { runAppend, runDestroy, runTask } from '../run'; import type { Factory } from '@ember/-internals/owner'; -import type { BootOptions } from '@ember/application/instance'; -import type { EngineInstanceOptions } from '@ember/engine/instance'; +import type { BootOptions, EngineInstanceOptions } from '@ember/engine/instance'; import type EngineInstance from '@ember/engine/instance'; import type { HelperFunction } from '@ember/-internals/glimmer/lib/helper';
true
Other
emberjs
ember.js
b584e5657a86cacb01fa5aa3dd018f9c2f6b0b4d.json
Relocate BootOptions interface
packages/internal-test-helpers/lib/test-cases/router-non-application.ts
@@ -9,9 +9,8 @@ import { ModuleBasedResolver } from '../test-resolver'; import AbstractTestCase from './abstract'; import buildOwner from '../build-owner'; import { runAppend, runDestroy } from '../run'; -import type { EngineInstanceOptions } from '@ember/engine/instance'; +import type { BootOptions, EngineInstanceOptions } from '@ember/engine/instance'; import type EngineInstance from '@ember/engine/instance'; -import type { BootOptions } from '@ember/application/instance'; import type { Factory } from '@ember/-internals/owner'; export default class RouterNonApplicationTestCase extends AbstractTestCase {
true
Other
emberjs
ember.js
debe5f7be0ba6df5dfcee4082f10bee28b5f541c.json
Add v4.7.0-beta.1 to CHANGELOG (cherry picked from commit 92284956ad8008fa177666649db698e4fd82394e)
CHANGELOG.md
@@ -1,5 +1,9 @@ # Ember Changelog +### v4.7.0-beta.1 (July 25, 2022) + +- [#20126](https://github.com/emberjs/ember.js/pull/20126) [BUGFIX] Replacing Firefox detection that used a deprecated browser API + ### v4.6.0 (July 25, 2022) - [#20125](https://github.com/emberjs/ember.js/pull/20125) [BUGFIX] Replace deprecated substr() method with substring() method.
false
Other
emberjs
ember.js
6dbd66eaa82fafcbc443f4f00403deeb7c6f5230.json
Add v4.6.0 to CHANGELOG (cherry picked from commit 4cf212827e5454f1fa720ea0341f8e3c338106bf)
CHANGELOG.md
@@ -1,13 +1,8 @@ # Ember Changelog -### v4.6.0-beta.2 (June 27, 2022) +### v4.6.0 (July 25, 2022) - [#20125](https://github.com/emberjs/ember.js/pull/20125) [BUGFIX] Replace deprecated substr() method with substring() method. -- [#20120](https://github.com/emberjs/ember.js/pull/20120) [BUGFIX] Adjust uniqueId() implementation to only generate valid selectors. - -### v4.6.0-beta.1 (June 13, 2022) - -No new external changes. ### v4.5.1 (July 25, 2022)
false
Other
emberjs
ember.js
cc699bd4cd50e808c1c0e95ac10cd60531541c3e.json
Add v4.5.1 to CHANGELOG (cherry picked from commit 6d34f631825acdf9cc0552a2e67b333b0be4445a)
CHANGELOG.md
@@ -9,6 +9,10 @@ No new external changes. +### v4.5.1 (July 25, 2022) + +- [#20120](https://github.com/emberjs/ember.js/pull/20120) [BUGFIX] Adjust uniqueId() implementation to only generate valid selectors. + ### v4.5.0 (June 13, 2022) - [#20052](https://github.com/emberjs/ember.js/pull/20052) / [#20055](https://github.com/emberjs/ember.js/pull/20055) [FEATURE] Add the default helper manager to implement [RFC #0756](https://github.com/emberjs/rfcs/blob/master/text/0756-helper-default-manager.md).
false
Other
emberjs
ember.js
e80113647ec9a0dfe4a82ebf80da578669183649.json
[DOCS]: fix inconsistencies in yield example
packages/@ember/-internals/glimmer/index.ts
@@ -162,8 +162,8 @@ ```html <div> - Start Date: July 1st - End Date: July 30th + Start date: July 1st + End date: July 30th </div> ``` @@ -177,7 +177,7 @@ </Banner> ``` - ```app/components/Banner.hbs + ```app/components/banner.hbs <div> {{yield "Hello title" "hello subtitle" "body text"}} </div> @@ -205,10 +205,10 @@ </Banner> ``` - ```app/components/banner.ts - import Title from './title'; - import Subtitle from './subtitle'; - import Body from './body'; + ```app/components/banner.js + import Title from './banner/title'; + import Subtitle from './banner/subtitle'; + import Body from './banner/body'; export default class Banner extends Component { Title = Title; @@ -270,13 +270,13 @@ ```app/components/banner/subtitle.hbs {{!-- note the use of ..attributes --}} - <div ...attributes> + <h2 ...attributes> {{yield}} - </div> + </h2> ``` ```app/components/banner/title.hbs - {{#if @variant "loud"}} + {{#if (eq @variant "loud")}} <h1 class="loud">{{yield}}</h1> {{else}} <h1 class="quiet">{{yield}}</h1>
false
Other
emberjs
ember.js
9741caacedb3fec9e82a4752c88345380594571d.json
Add v4.6.0-beta.2 to CHANGELOG (cherry picked from commit 3786bcbbf7745c0b69e3e7c8506138411cf28e9c)
CHANGELOG.md
@@ -1,5 +1,10 @@ # Ember Changelog +### v4.6.0-beta.2 (June 27, 2022) + +- [#20125](https://github.com/emberjs/ember.js/pull/20125) [BUGFIX] Replace deprecated substr() method with substring() method. +- [#20120](https://github.com/emberjs/ember.js/pull/20120) [BUGFIX] Adjust uniqueId() implementation to only generate valid selectors. + ### v4.6.0-beta.1 (June 13, 2022) No new external changes.
false
Other
emberjs
ember.js
42d018a93e36e0aa41806d3276591c0fe4c14a16.json
Remove browser detection for IE
packages/@ember/-internals/browser-environment/index.ts
@@ -2,8 +2,6 @@ import hasDom from './lib/has-dom'; declare const chrome: unknown; declare const opera: unknown; -declare const MSInputMethodContext: unknown; -declare const documentMode: unknown; export { default as hasDOM } from './lib/has-dom'; export const window = hasDom ? self : null; @@ -12,6 +10,3 @@ export const history = hasDom ? self.history : null; export const userAgent = hasDom ? self.navigator.userAgent : 'Lynx (textmode)'; export const isChrome = hasDom ? typeof chrome === 'object' && !(typeof opera === 'object') : false; export const isFirefox = hasDom ? /Firefox|FxiOS/.test(userAgent) : false; -export const isIE = hasDom - ? typeof MSInputMethodContext !== 'undefined' && typeof documentMode !== 'undefined' - : false;
false
Other
emberjs
ember.js
39bd7a6989d4b4fa7c362d61ec694251d2dfe808.json
Fix typo in instance.ts transion -> transition
packages/@ember/application/instance.ts
@@ -248,7 +248,7 @@ class ApplicationInstance extends EngineInstance { Navigate the instance to a particular URL. This is useful in tests, for example, or to tell the app to start at a particular URL. This method returns a promise that resolves with the app instance when the transition - is complete, or rejects if the transion was aborted due to an error. + is complete, or rejects if the transition was aborted due to an error. @public @param url {String} the destination URL
false
Other
emberjs
ember.js
f8812ee1d756d71cb2f3194ff7ec458dcdbd2d21.json
Application class: convert docs to ES6 syntax
packages/@ember/application/lib/application.ts
@@ -43,11 +43,11 @@ import type { SimpleDocument, SimpleElement } from '@simple-dom/interface'; initialized. ```app/app.js - const App = Application.extend({ + export default class App extends Application { ready() { // your code here } - }) + } ``` Because `Application` ultimately inherits from `Ember.Namespace`, any classes @@ -84,12 +84,12 @@ import type { SimpleDocument, SimpleElement } from '@simple-dom/interface'; ```app/app.js import Application from '@ember/application'; - let App = Application.extend({ - customEvents: { + export default class App extends Application { + customEvents = { // add support for the paste event paste: 'paste' } - }); + } ``` To prevent Ember from setting up a listener for a default event, @@ -99,13 +99,13 @@ import type { SimpleDocument, SimpleElement } from '@simple-dom/interface'; ```app/app.js import Application from '@ember/application'; - let App = Application.extend({ - customEvents: { + export default class App extends Application { + customEvents = { // prevent listeners for mouseenter/mouseleave events mouseenter: null, mouseleave: null } - }); + } ``` By default, the application sets up these event listeners on the document @@ -119,9 +119,9 @@ import type { SimpleDocument, SimpleElement } from '@simple-dom/interface'; ```app/app.js import Application from '@ember/application'; - let App = Application.extend({ - rootElement: '#ember-app' - }); + export default class App extends Application { + rootElement = '#ember-app' + } ``` The `rootElement` can be either a DOM element or a CSS selector
false
Other
emberjs
ember.js
5a77a4312accd672f29b48b73db2b78745335ae7.json
Add v4.6.0-beta.1 to CHANGELOG (cherry picked from commit e0485faba3e56afe1e3e7a20af4e150b6f962877)
CHANGELOG.md
@@ -1,5 +1,9 @@ # Ember Changelog +### v4.6.0-beta.1 (June 13, 2022) + +No new external changes. + ### v4.5.0 (June 13, 2022) - [#20052](https://github.com/emberjs/ember.js/pull/20052) / [#20055](https://github.com/emberjs/ember.js/pull/20055) [FEATURE] Add the default helper manager to implement [RFC #0756](https://github.com/emberjs/rfcs/blob/master/text/0756-helper-default-manager.md).
false
Other
emberjs
ember.js
fa7db213b2f870bce4b153c1167746bff1f6a209.json
Add v4.5.0 to CHANGELOG (cherry picked from commit 311760db432da20977b307b2805e9761b8917228)
CHANGELOG.md
@@ -1,22 +1,18 @@ # Ember Changelog -### v4.4.2 (June 13, 2022) +### v4.5.0 (June 13, 2022) -- [#20114](https://github.com/emberjs/ember.js/pull/20114) [BUGFIX] Fix generated import paths for test setup functions in addons +- [#20052](https://github.com/emberjs/ember.js/pull/20052) / [#20055](https://github.com/emberjs/ember.js/pull/20055) [FEATURE] Add the default helper manager to implement [RFC #0756](https://github.com/emberjs/rfcs/blob/master/text/0756-helper-default-manager.md). +- [#20053](https://github.com/emberjs/ember.js/pull/20053) [FEATURE] Expose `renderSettled` from `@ember/renderer` to enable implementation of [RFC #0785](https://github.com/emberjs/rfcs/blob/master/text/0785-remove-set-get-in-tests.md). -### v4.5.0-beta.2 (June 6, 2022) +### v4.4.2 (June 13, 2022) -- [#20082](https://github.com/emberjs/ember.js/pull/20082) [BUGFIX] Fix blueprint generation +- [#20114](https://github.com/emberjs/ember.js/pull/20114) [BUGFIX] Fix generated import paths for test setup functions in addons ### v4.4.1 (May 31, 2022) - [#20082](https://github.com/emberjs/ember.js/pull/20082) [BUGFIX] Fix blueprints publication -### v4.5.0-beta.1 (May 2, 2022) - -- [#20052](https://github.com/emberjs/ember.js/pull/20052) / [#20055](https://github.com/emberjs/ember.js/pull/20055) [FEATURE] Add the default helper manager to implement [RFC #0756](https://github.com/emberjs/rfcs/blob/master/text/0756-helper-default-manager.md). -- [#20053](https://github.com/emberjs/ember.js/pull/20053) [FEATURE] Expose `renderSettled` from `@ember/renderer` to enable implementation of [RFC #0785](https://github.com/emberjs/rfcs/blob/master/text/0785-remove-set-get-in-tests.md). - ### v4.4.0 (May 2, 2022) - [#19882](https://github.com/emberjs/ember.js/pull/19882) / [#20005](https://github.com/emberjs/ember.js/pull/20005) [FEATURE] Implement the `unique-id` helper per [RFC #0659](https://github.com/emberjs/rfcs/blob/master/text/0659-unique-id-helper.md).
false
Other
emberjs
ember.js
c18edfca05598cdc6e683566ac0ffaa64dd9de04.json
Add v4.4.2 to CHANGELOG (cherry picked from commit 0527cdfb1380e566424b57f2764ef01998acb810)
CHANGELOG.md
@@ -1,5 +1,9 @@ # Ember Changelog +### v4.4.2 (June 13, 2022) + +- [#20114](https://github.com/emberjs/ember.js/pull/20114) [BUGFIX] Fix generated import paths for test setup functions in addons + ### v4.5.0-beta.2 (June 6, 2022) - [#20082](https://github.com/emberjs/ember.js/pull/20082) [BUGFIX] Fix blueprint generation
false
Other
emberjs
ember.js
2a06e7dc1895b78759522dda062d1897b016172d.json
Remove internal files in `blueprints-js` folder
blueprints-js/-addon-import.js
@@ -1,48 +0,0 @@ -'use strict'; - -const stringUtil = require('ember-cli-string-utils'); -const path = require('path'); -const inflector = require('inflection'); - -module.exports = { - description: 'Generates an import wrapper.', - - fileMapTokens: function () { - return { - __name__: function (options) { - return options.dasherizedModuleName; - }, - __path__: function (options) { - return inflector.pluralize(options.locals.blueprintName); - }, - __root__: function (options) { - if (options.inRepoAddon) { - return path.join('lib', options.inRepoAddon, 'app'); - } - return 'app'; - }, - }; - }, - - locals: function (options) { - let addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); - let addonName = stringUtil.dasherize(addonRawName); - let fileName = stringUtil.dasherize(options.entity.name); - let blueprintName = options.originBlueprintName; - let modulePathSegments = [ - addonName, - inflector.pluralize(options.originBlueprintName), - fileName, - ]; - - if (blueprintName.match(/-addon/)) { - blueprintName = blueprintName.substr(0, blueprintName.indexOf('-addon')); - modulePathSegments = [addonName, inflector.pluralize(blueprintName), fileName]; - } - - return { - modulePath: modulePathSegments.join('/'), - blueprintName: blueprintName, - }; - }, -};
true
Other
emberjs
ember.js
2a06e7dc1895b78759522dda062d1897b016172d.json
Remove internal files in `blueprints-js` folder
blueprints-js/test-framework-detector.js
@@ -1,60 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const VersionChecker = require('ember-cli-version-checker'); - -module.exports = function (blueprint) { - blueprint.supportsAddon = function () { - return false; - }; - - blueprint.filesPath = function () { - let type; - const qunitRfcVersion = 'qunit-rfc-232'; - const mochaRfcVersion = 'mocha-rfc-232'; - const mochaVersion = 'mocha-0.12'; - - let dependencies = this.project.dependencies(); - if ('ember-qunit' in dependencies) { - type = qunitRfcVersion; - } else if ('ember-cli-qunit' in dependencies) { - let checker = new VersionChecker(this.project); - if ( - fs.existsSync(`${this.path}/${qunitRfcVersion}-files`) && - checker.for('ember-cli-qunit', 'npm').gte('4.2.0') - ) { - type = qunitRfcVersion; - } else { - type = 'qunit'; - } - } else if ('ember-mocha' in dependencies) { - let checker = new VersionChecker(this.project); - if ( - fs.existsSync(`${this.path}/${mochaRfcVersion}-files`) && - checker.for('ember-mocha', 'npm').gte('0.14.0') - ) { - type = mochaRfcVersion; - } else { - type = mochaVersion; - } - } else if ('ember-cli-mocha' in dependencies) { - let checker = new VersionChecker(this.project); - if ( - fs.existsSync(`${this.path}/${mochaVersion}-files`) && - checker.for('ember-cli-mocha', 'npm').gte('0.12.0') - ) { - type = mochaVersion; - } else { - type = 'mocha'; - } - } else { - this.ui.writeLine("Couldn't determine test style - using QUnit"); - type = 'qunit'; - } - - return path.join(this.path, type + '-files'); - }; - - return blueprint; -};
true
Other
emberjs
ember.js
75cd214c1165ad9c7bec274031eecb6404658225.json
Add v4.5.0-beta.2 to CHANGELOG (cherry picked from commit 4443f5e554bf6353b7f4a2cda4a842bd47fd75ad)
CHANGELOG.md
@@ -1,5 +1,9 @@ # Ember Changelog +### v4.5.0-beta.2 (June 6, 2022) + +- [#20082](https://github.com/emberjs/ember.js/pull/20082) [BUGFIX] Fix blueprint generation + ### v4.4.1 (May 31, 2022) - [#20082](https://github.com/emberjs/ember.js/pull/20082) [BUGFIX] Fix blueprints publication
false
Other
emberjs
ember.js
a5027fefdcc433eb2ebd50d42fd6b9b5e89d7d01.json
Add updated SAFETY comment to `spaceship` body
packages/@ember/-internals/runtime/lib/compare.ts
@@ -36,6 +36,9 @@ type Compare = -1 | 0 | 1; // `._________`-. `. `.___ // SSt `------'` function spaceship(a: number, b: number): Compare { + // SAFETY: `Math.sign` always returns `-1` for negative, `0` for zero, and `1` + // for positive numbers. (The extra precision is useful for the way we use + // this in the context of `compare`.) return Math.sign(a - b) as Compare; }
false
Other
emberjs
ember.js
09a73ada1e5140ea0f0179dcbe6245255c336674.json
Convert @ember/test to TS
packages/@ember/test/adapter.js
@@ -1,3 +0,0 @@ -import { Test } from 'ember-testing'; - -export default Test.Adapter;
true
Other
emberjs
ember.js
09a73ada1e5140ea0f0179dcbe6245255c336674.json
Convert @ember/test to TS
packages/@ember/test/adapter.ts
@@ -0,0 +1,3 @@ +import { Adapter } from 'ember-testing'; + +export default Adapter;
true
Other
emberjs
ember.js
09a73ada1e5140ea0f0179dcbe6245255c336674.json
Convert @ember/test to TS
packages/@ember/test/index.ts
@@ -1,10 +1,11 @@ import require, { has } from 'require'; +import { type Test } from 'ember-testing'; -export let registerAsyncHelper; -export let registerHelper; -export let registerWaiter; -export let unregisterHelper; -export let unregisterWaiter; +export let registerAsyncHelper: typeof Test['registerAsyncHelper'] | (() => never); +export let registerHelper: typeof Test['registerHelper'] | (() => never); +export let registerWaiter: typeof Test['registerWaiter'] | (() => never); +export let unregisterHelper: typeof Test['unregisterHelper'] | (() => never); +export let unregisterWaiter: typeof Test['unregisterWaiter'] | (() => never); if (has('ember-testing')) { let { Test } = require('ember-testing');
true
Other
emberjs
ember.js
8c6a1594b72ecb9e0f56161e08c815b76f4bb21a.json
Improve types for array internals
packages/@ember/-internals/metal/lib/array.ts
@@ -1,10 +1,13 @@ -import type { Array as EmberArray, MutableArray, NativeArray } from '@ember/-internals/runtime'; +import type { Array as EmberArray, MutableArray } from '@ember/-internals/runtime'; +import { assert } from '@ember/debug'; import { arrayContentDidChange, arrayContentWillChange } from './array_events'; import { addListener, removeListener } from './events'; const EMPTY_ARRAY = Object.freeze([]); -interface ObservedObject<T> extends EmberArray<T> { +type ObservedArray<T> = (T[] | EmberArray<T>) & ObservedObject; + +interface ObservedObject { _revalidate?: () => void; } @@ -16,16 +19,23 @@ export function objectAt<T>(array: T[] | EmberArray<T>, index: number): T | unde } } +// Ideally, we'd use MutableArray.detect but for unknown reasons this causes +// the node tests to fail strangely. +function isMutableArray<T>(obj: unknown): obj is MutableArray<T> { + return obj != null && typeof (obj as MutableArray<T>).replace === 'function'; +} + export function replace<T>( - array: NativeArray<T> | MutableArray<T>, + array: T[] | MutableArray<T>, start: number, deleteCount: number, - items: T[] = EMPTY_ARRAY as [] + items: readonly T[] = EMPTY_ARRAY as [] ): void { - if (Array.isArray(array)) { - replaceInNativeArray(array, start, deleteCount, items); - } else { + if (isMutableArray(array)) { array.replace(start, deleteCount, items); + } else { + assert('Can only replace content of a native array or MutableArray', Array.isArray(array)); + replaceInNativeArray(array, start, deleteCount, items); } } @@ -34,7 +44,7 @@ const CHUNK_SIZE = 60000; // To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time. // See https://code.google.com/p/chromium/issues/detail?id=56588 for more details. export function replaceInNativeArray<T>( - array: T[] | NativeArray<T>, + array: T[], start: number, deleteCount: number, items: ReadonlyArray<T> @@ -61,18 +71,18 @@ interface ArrayObserverOptions { } type Operation<T> = ( - obj: ObservedObject<T>, + obj: ObservedArray<T>, eventName: string, target: object | Function | null, callbackName: string ) => void; function arrayObserversHelper<T>( - obj: ObservedObject<T>, + obj: ObservedArray<T>, target: object | Function | null, opts: ArrayObserverOptions, operation: Operation<T> -): ObservedObject<T> { +): ObservedArray<T> { let { willChange, didChange } = opts; operation(obj, '@array:before', target, willChange); @@ -91,14 +101,14 @@ export function addArrayObserver<T>( array: EmberArray<T>, target: object | Function | null, opts: ArrayObserverOptions -): ObservedObject<T> { +): ObservedArray<T> { return arrayObserversHelper(array, target, opts, addListener); } export function removeArrayObserver<T>( - array: EmberArray<T>, + array: T[] | EmberArray<T>, target: object | Function | null, opts: ArrayObserverOptions -): ObservedObject<T> { +): ObservedArray<T> { return arrayObserversHelper(array, target, opts, removeListener); }
true
Other
emberjs
ember.js
8c6a1594b72ecb9e0f56161e08c815b76f4bb21a.json
Improve types for array internals
packages/@ember/-internals/metal/lib/mixin.ts
@@ -672,7 +672,9 @@ export default class Mixin { /** @internal */ keys() { - return _keys(this); + let keys = _keys(this); + assert('[BUG] Missing keys for mixin!', keys); + return keys; } /** @internal */ @@ -739,16 +741,16 @@ function _detect(curMixin: Mixin, targetMixin: Mixin, seen = new Set()): boolean return false; } -function _keys(mixin: Mixin, ret = new Set(), seen = new Set()) { +function _keys(mixin: Mixin, ret = new Set<string>(), seen = new Set()) { if (seen.has(mixin)) { return; } seen.add(mixin); if (mixin.properties) { let props = Object.keys(mixin.properties); - for (let i = 0; i < props.length; i++) { - ret.add(props[i]); + for (let prop of props) { + ret.add(prop); } } else if (mixin.mixins) { mixin.mixins.forEach((x: any) => _keys(x, ret, seen));
true
Other
emberjs
ember.js
8c6a1594b72ecb9e0f56161e08c815b76f4bb21a.json
Improve types for array internals
packages/@ember/-internals/runtime/lib/mixins/array.d.ts
@@ -1,110 +0,0 @@ -import type { Mixin } from '@ember/-internals/metal'; -import type { AnyFn } from '@ember/-internals/utils/types'; -import type Enumerable from './enumerable'; -import type MutableEnumerable from './mutable_enumerable'; - -type Value<T, K extends string> = K extends keyof T ? T[K] : unknown; - -interface EmberArray<T> extends Enumerable { - length: number; - objectAt(idx: number): T | undefined; - objectsAt(indexes: number[]): Array<T | undefined>; - firstObject: T | undefined; - lastObject: T | undefined; - slice(beginIndex?: number, endIndex?: number): NativeArray<T>; - indexOf(object: T, startAt?: number): number; - lastIndexOf(object: T, startAt?: number): number; - forEach<Target>( - callback: (this: Target, item: T, index: number, arr: this) => void, - target?: Target - ): this; - getEach<K extends string>(key: K): NativeArray<Value<T, K>>; - setEach<K extends string>(key: K, value: Value<T, K>): this; - map<U, Target>( - callback: (this: Target, item: T, index: number, arr: this) => U, - target?: Target - ): NativeArray<U>; - mapBy<K extends string>(key: K): NativeArray<Value<T, K>>; - filter<Target>( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): NativeArray<T>; - reject<Target>( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): NativeArray<T>; - filterBy(key: string): NativeArray<T>; - rejectBy(key: string): NativeArray<T>; - find<Target = void>( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): T | undefined; - findBy<K extends string>(key: K, value?: Value<T, K>): T | undefined; - every<Target = void>( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): boolean; - isEvery<K extends string>(key: K, value?: Value<T, K>): boolean; - any<Target = void>( - callback: (this: Target, item: T, index: number, arr: this) => unknown, - target?: Target - ): boolean; - isAny<K extends string>(key: K, value?: Value<T, K>): boolean; - reduce<V>( - callback: (summation: V, current: T, index: number, arr: this) => V, - initialValue?: V - ): V; - invoke<K extends string>( - methodName: K, - ...args: Value<T, K> extends AnyFn ? Parameters<Value<T, K>> : unknown[] - ): NativeArray<Value<T, K> extends AnyFn ? ReturnType<Value<T, K>> : unknown>; - toArray(): T[]; - compact(): NativeArray<Exclude<T, null>>; - includes(object: T, startAt?: number): boolean; - sortBy(key: string): T[]; - uniq(): NativeArray<T>; - uniqBy(key: string): NativeArray<T>; - without(value: T): NativeArray<T>; -} - -declare const EmberArray: Mixin; -export default EmberArray; - -interface MutableArray<T> extends EmberArray<T>, MutableEnumerable { - replace(idx: number, amt: number, objects?: T[]): void; - clear(): this; - insertAt(idx: number, object: T): this; - removeAt(start: number, len: number): this; - pushObject(obj: T): this; - pushObjects(objects: T[]): this; - popObject(): T | undefined; - shiftObject(): T | null | undefined; - unshiftObject(object: T): this; - unshiftObjects(objects: T[]): this; - reverseObjects(): this; - setObjects(object: T[]): this; - removeObject(object: T): this; - removeObjects(objects: T[]): this; - addObject(obj: T): this; - addObjects(objects: T[]): this; -} - -declare const MutableArray: Mixin; -export { MutableArray }; - -// NOTE: We have to Omit some definitions from Array because MutableArray defines them differently. -interface NativeArray<T> - extends Omit<Array<T>, 'every' | 'filter' | 'find' | 'forEach' | 'map' | 'reduce' | 'slice'>, - MutableArray<T> {} -declare const NativeArray: Array<unknown>; -export { NativeArray }; - -export function A<A>(arr: A): A extends Array<infer V> ? NativeArray<V> : NativeArray<unknown>; -export function A<T>(): NativeArray<T>; - -export function removeAt<T>(array: T[] | EmberArray<T>, start: number, len: number): EmberArray<T>; -export function uniqBy<T>( - array: T[] | EmberArray<T>, - keyOrFunc: string | ((item: T) => unknown) -): T[] | EmberArray<T>; -export function isArray(obj: unknown): boolean;
true
Other
emberjs
ember.js
8c6a1594b72ecb9e0f56161e08c815b76f4bb21a.json
Improve types for array internals
packages/@ember/-internals/runtime/lib/mixins/array.ts
@@ -3,7 +3,7 @@ */ import { DEBUG } from '@glimmer/env'; import { PROXY_CONTENT } from '@ember/-internals/metal'; -import { setEmberArray } from '@ember/-internals/utils'; +import { isEmberArray, setEmberArray } from '@ember/-internals/utils'; import { get, set, @@ -22,17 +22,24 @@ import { ENV } from '@ember/-internals/environment'; import Observable from '../mixins/observable'; import MutableEnumerable from './mutable_enumerable'; import { typeOf } from '../type-of'; +import type { AnyFn } from '@ember/-internals/utils/types'; +import type { ComputedPropertyCallback } from '@ember/-internals/metal/lib/computed'; -const EMPTY_ARRAY = Object.freeze([]); +type Value<T, K extends string> = K extends keyof T ? T[K] : unknown; -const identityFunction = (item) => item; +const EMPTY_ARRAY = Object.freeze([] as const); -export function uniqBy(array, key = identityFunction) { +const identityFunction = <T>(item: T) => item; + +export function uniqBy<T>( + array: T[] | EmberArray<T>, + keyOrFunc: string | ((item: T) => unknown) = identityFunction +): T[] | EmberArray<T> { assert(`first argument passed to \`uniqBy\` should be array`, isArray(array)); - let ret = A(); + let ret = A<T>(); let seen = new Set(); - let getter = typeof key === 'function' ? key : (item) => get(item, key); + let getter = typeof keyOrFunc === 'function' ? keyOrFunc : (item: T) => get(item, keyOrFunc); array.forEach((item) => { let val = getter(item); @@ -45,58 +52,86 @@ export function uniqBy(array, key = identityFunction) { return ret; } -function iter(key, value) { - let valueProvided = arguments.length === 2; - return valueProvided ? (item) => value === get(item, key) : (item) => Boolean(get(item, key)); +function iter<T>(key: string): (item: T) => boolean; +function iter<T>(key: string, value: unknown): (item: T) => boolean; +function iter<T>(...args: [key: string] | [key: string, value: unknown]) { + let valueProvided = args.length === 2; + let [key, value] = args; + + return valueProvided + ? (item: T) => value === get(item, key) + : (item: T) => Boolean(get(item, key)); } -function findIndex(array, predicate, startAt) { +function findIndex<T>( + array: EmberArray<T>, + predicate: (item: T, index: number, arr: EmberArray<T>) => unknown, + startAt: number +): number { let len = array.length; for (let index = startAt; index < len; index++) { - let item = objectAt(array, index); + // SAFETY: Because we're checking the index this value should always be set. + let item = objectAt(array, index)!; if (predicate(item, index, array)) { return index; } } return -1; } -function find(array, callback, target) { +function find<T, Target>( + array: EmberArray<T>, + callback: (this: Target | null, item: T, index: number, arr: EmberArray<T>) => unknown, + target: Target | null = null +) { let predicate = callback.bind(target); let index = findIndex(array, predicate, 0); return index === -1 ? undefined : objectAt(array, index); } -function any(array, callback, target) { +function any<T, Target>( + array: EmberArray<T>, + callback: (this: Target | null, item: T, index: number, arr: EmberArray<T>) => unknown, + target: Target | null = null +) { let predicate = callback.bind(target); return findIndex(array, predicate, 0) !== -1; } -function every(array, callback, target) { +function every<T, Target>( + array: EmberArray<T>, + callback: (this: Target | null | void, item: T, index: number, arr: EmberArray<T>) => unknown, + target: Target | null = null +) { let cb = callback.bind(target); - let predicate = (item, index, array) => !cb(item, index, array); + let predicate = (item: T, index: number, array: EmberArray<T>) => !cb(item, index, array); return findIndex(array, predicate, 0) === -1; } -function indexOf(array, val, startAt = 0, withNaNCheck) { +function indexOf<T>(array: EmberArray<T>, val: T, startAt = 0, withNaNCheck: boolean) { let len = array.length; if (startAt < 0) { startAt += len; } // SameValueZero comparison (NaN !== NaN) - let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val; + let predicate = + withNaNCheck && val !== val ? (item: T) => item !== item : (item: T) => item === val; return findIndex(array, predicate, startAt); } -export function removeAt(array, index, len = 1) { +export function removeAt<T, A extends T[] | MutableArray<T>>( + array: A, + index: number, + len?: number +): A { assert(`\`removeAt\` index provided is out of range`, index > -1 && index < array.length); - replace(array, index, len, EMPTY_ARRAY); + replace(array, index, len ?? 1, EMPTY_ARRAY); return array; } -function insertAt(array, index, item) { +function insertAt<T>(array: MutableArray<T>, index: number, item: T) { assert(`\`insertAt\` index provided is out of range`, index > -1 && index <= array.length); replace(array, index, 0, [item]); return item; @@ -130,30 +165,35 @@ function insertAt(array, index, item) { @return {Boolean} true if the passed object is an array or Array-like @public */ -export function isArray(_obj) { - let obj = _obj; - if (DEBUG && typeof _obj === 'object' && _obj !== null) { - let possibleProxyContent = _obj[PROXY_CONTENT]; +export function isArray(obj: unknown): obj is ArrayLike<unknown> | EmberArray<unknown> { + if (DEBUG && typeof obj === 'object' && obj !== null) { + // SAFETY: Property read checks are safe if it's an object + let possibleProxyContent = (obj as any)[PROXY_CONTENT]; if (possibleProxyContent !== undefined) { obj = possibleProxyContent; } } - if (!obj || obj.setInterval) { + // SAFETY: Property read checks are safe if it's an object + if (!obj || (obj as any).setInterval) { return false; } - if (Array.isArray(obj) || ArrayMixin.detect(obj)) { + + if (Array.isArray(obj) || EmberArray.detect(obj)) { return true; } let type = typeOf(obj); if ('array' === type) { return true; } - let length = obj.length; + + // SAFETY: Property read checks are safe if it's an object + let length = (obj as any).length; if (typeof length === 'number' && length === length && 'object' === type) { return true; } + return false; } @@ -163,13 +203,13 @@ export function isArray(_obj) { applied to `Array.prototype` we need to ensure that we do not add _any_ new enumerable properties. */ -function nonEnumerableComputed() { - let property = computed(...arguments); +function nonEnumerableComputed(callback: ComputedPropertyCallback) { + let property = computed(callback); property.enumerable = false; return property; } -function mapBy(key) { +function mapBy<T>(this: EmberArray<T>, key: string) { return this.map((next) => get(next, key)); } @@ -209,7 +249,68 @@ function mapBy(key) { @since Ember 0.9.0 @public */ -const ArrayMixin = Mixin.create(Enumerable, { +interface EmberArray<T> extends Enumerable { + length: number; + objectAt(idx: number): T | undefined; + objectsAt(indexes: number[]): Array<T | undefined>; + firstObject: T | undefined; + lastObject: T | undefined; + slice(beginIndex?: number, endIndex?: number): NativeArray<T>; + indexOf(object: T, startAt?: number): number; + lastIndexOf(object: T, startAt?: number): number; + forEach<Target>( + callback: (this: Target, item: T, index: number, arr: this) => void, + target?: Target + ): this; + getEach<K extends string>(key: K): NativeArray<Value<T, K>>; + setEach<K extends string>(key: K, value: Value<T, K>): this; + map<U, Target>( + callback: (this: Target, item: T, index: number, arr: this) => U, + target?: Target + ): NativeArray<U>; + mapBy<K extends string>(key: K): NativeArray<Value<T, K>>; + filter<Target>( + callback: (this: Target, item: T, index: number, arr: this) => unknown, + target?: Target + ): NativeArray<T>; + reject<Target>( + callback: (this: Target, item: T, index: number, arr: this) => unknown, + target?: Target + ): NativeArray<T>; + filterBy(key: string, value?: unknown): NativeArray<T>; + rejectBy(key: string, value?: unknown): NativeArray<T>; + find<Target = void>( + callback: (this: Target, item: T, index: number, arr: this) => unknown, + target?: Target + ): T | undefined; + findBy<K extends string>(key: K, value?: Value<T, K>): T | undefined; + every<Target = void>( + callback: (this: Target, item: T, index: number, arr: this) => unknown, + target?: Target + ): boolean; + isEvery<K extends string>(key: K, value?: Value<T, K>): boolean; + any<Target = void>( + callback: (this: Target, item: T, index: number, arr: this) => unknown, + target?: Target + ): boolean; + isAny<K extends string>(key: K, value?: Value<T, K>): boolean; + reduce<V>( + callback: (summation: V, current: T, index: number, arr: this) => V, + initialValue?: V + ): V; + invoke<K extends string>( + methodName: K, + ...args: Value<T, K> extends AnyFn ? Parameters<Value<T, K>> : unknown[] + ): NativeArray<Value<T, K> extends AnyFn ? ReturnType<Value<T, K>> : unknown>; + toArray(): T[]; + compact(): NativeArray<Exclude<T, null>>; + includes(object: T, startAt?: number): boolean; + sortBy(key: string): T[]; + uniq(): NativeArray<T>; + uniqBy(key: string): NativeArray<T>; + without(value: T): NativeArray<T>; +} +const EmberArray = Mixin.create(Enumerable, { init() { this._super(...arguments); setEmberArray(this); @@ -265,7 +366,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} @public */ - objectsAt(indexes) { + objectsAt(indexes: number[]) { return indexes.map((idx) => objectAt(this, idx)); }, @@ -291,7 +392,7 @@ const ArrayMixin = Mixin.create(Enumerable, { get() { return this; }, - set(key, value) { + set(_key, value) { this.replace(0, this.length, value); return this; }, @@ -353,21 +454,24 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} New array with specified slice @public */ - slice(beginIndex = 0, endIndex) { + slice(beginIndex = 0, endIndex?: number) { let ret = A(); let length = this.length; if (beginIndex < 0) { beginIndex = length + beginIndex; } + let validatedEndIndex: number; if (endIndex === undefined || endIndex > length) { - endIndex = length; + validatedEndIndex = length; } else if (endIndex < 0) { - endIndex = length + endIndex; + validatedEndIndex = length + endIndex; + } else { + validatedEndIndex = endIndex; } - while (beginIndex < endIndex) { + while (beginIndex < validatedEndIndex) { ret[ret.length] = objectAt(this, beginIndex++); } @@ -412,7 +516,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ - indexOf(object, startAt) { + indexOf<T>(object: T, startAt?: number) { return indexOf(this, object, startAt, false); }, @@ -450,7 +554,7 @@ const ArrayMixin = Mixin.create(Enumerable, { if not found @public */ - lastIndexOf(object, startAt) { + lastIndexOf<T>(object: T, startAt?: number) { let len = this.length; if (startAt === undefined || startAt >= len) { @@ -517,7 +621,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Object} receiver @public */ - forEach(callback, target = null) { + forEach(callback: <T>(item: T, index: number, arr: EmberArray<T>) => void, target = null) { assert('`forEach` expects a function as first argument.', typeof callback === 'function'); let length = this.length; @@ -572,8 +676,8 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Object} receiver @public */ - setEach(key, value) { - return this.forEach((item) => set(item, key, value)); + setEach(key: string, value: unknown) { + return this.forEach((item: object) => set(item, key, value)); }, /** @@ -610,7 +714,11 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} The mapped array. @public */ - map(callback, target = null) { + map<T>( + this: EmberArray<T>, + callback: (item: T, index: number, arr: EmberArray<T>) => unknown, + target = null + ) { assert('`map` expects a function as first argument.', typeof callback === 'function'); let ret = A(); @@ -700,7 +808,11 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} A filtered array. @public */ - filter(callback, target = null) { + filter<T>( + this: EmberArray<T>, + callback: (item: T, index: number, arr: EmberArray<T>) => unknown, + target = null + ) { assert('`filter` expects a function as first argument.', typeof callback === 'function'); let ret = A(); @@ -754,9 +866,14 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} A rejected array. @public */ - reject(callback, target = null) { + reject<T>( + this: EmberArray<T>, + callback: (item: T, index: number, arr: EmberArray<T>) => unknown, + target = null + ) { assert('`reject` expects a function as first argument.', typeof callback === 'function'); return this.filter(function () { + // @ts-expect-error TS doesn't like us using arguments like this return !callback.apply(target, arguments); }); }, @@ -782,6 +899,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ filterBy() { + // @ts-expect-error TS doesn't like the ...arguments spread here. return this.filter(iter(...arguments)); }, @@ -809,6 +927,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ rejectBy() { + // @ts-expect-error TS doesn't like the ...arguments spread here. return this.reject(iter(...arguments)); }, @@ -854,7 +973,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Object} Found item or `undefined`. @public */ - find(callback, target = null) { + find(callback: <T>(item: T, index: number, arr: EmberArray<T>) => unknown, target = null) { assert('`find` expects a function as first argument.', typeof callback === 'function'); return find(this, callback, target); }, @@ -888,7 +1007,9 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ findBy() { - return find(this, iter(...arguments)); + // @ts-expect-error TS doesn't like the ...arguments spread here. + let callback = iter(...arguments); + return find(this, callback); }, /** @@ -928,7 +1049,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Boolean} @public */ - every(callback, target = null) { + every(callback: <T>(item: T, index: number, arr: EmberArray<T>) => unknown, target = null) { assert('`every` expects a function as first argument.', typeof callback === 'function'); return every(this, callback, target); }, @@ -972,7 +1093,9 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ isEvery() { - return every(this, iter(...arguments)); + // @ts-expect-error TS doesn't like the ...arguments spread here. + let callback = iter(...arguments); + return every(this, callback); }, /** @@ -1014,7 +1137,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Boolean} `true` if the passed function returns `true` for any item @public */ - any(callback, target = null) { + any(callback: <T>(item: T, index: number, arr: EmberArray<T>) => unknown, target = null) { assert('`any` expects a function as first argument.', typeof callback === 'function'); return any(this, callback, target); }, @@ -1044,7 +1167,9 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ isAny() { - return any(this, iter(...arguments)); + // @ts-expect-error TS doesn't like us using arguments like this + let callback = iter(...arguments); + return any(this, callback); }, /** @@ -1102,7 +1227,11 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ // FIXME: When called without initialValue, behavior does not match native behavior - reduce(callback, initialValue) { + reduce<T, V>( + this: EmberArray<T>, + callback: (summation: V, current: T, index: number, arr: EmberArray<T>) => V, + initialValue: V + ) { assert('`reduce` expects a function as first argument.', typeof callback === 'function'); let ret = initialValue; @@ -1144,10 +1273,11 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} return values from calling invoke. @public */ - invoke(methodName, ...args) { + invoke<T>(this: EmberArray<T>, methodName: string, ...args: unknown[]) { let ret = A(); - this.forEach((item) => ret.push(item[methodName]?.(...args))); + // SAFETY: This is not entirely safe and the code will not work with Ember proxies + this.forEach((item: T) => ret.push((item as any)[methodName]?.(...args))); return ret; }, @@ -1160,8 +1290,8 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} the object as an array. @public */ - toArray() { - return this.map((item) => item); + toArray<T>(this: EmberArray<T>) { + return this.map((item: T) => item); }, /** @@ -1176,8 +1306,8 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Array} the array without null and undefined elements. @public */ - compact() { - return this.filter((value) => value != null); + compact<T>(this: EmberArray<T>) { + return this.filter((value: T) => value != null); }, /** @@ -1209,7 +1339,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {Boolean} `true` if object is found in the array. @public */ - includes(object, startAt) { + includes<T>(this: EmberArray<T>, object: T, startAt?: number) { return indexOf(this, object, startAt, true) !== -1; }, @@ -1238,10 +1368,10 @@ const ArrayMixin = Mixin.create(Enumerable, { @since 1.2.0 @public */ - sortBy() { + sortBy<T>(this: EmberArray<T>) { let sortKeys = arguments; - return this.toArray().sort((a, b) => { + return this.toArray().sort((a: T, b: T) => { for (let i = 0; i < sortKeys.length; i++) { let key = sortKeys[i]; let propA = get(a, key); @@ -1294,7 +1424,7 @@ const ArrayMixin = Mixin.create(Enumerable, { @public */ - uniqBy(key) { + uniqBy(key: string) { return uniqBy(this, key); }, @@ -1313,13 +1443,13 @@ const ArrayMixin = Mixin.create(Enumerable, { @return {EmberArray} @public */ - without(value) { + without<T>(this: EmberArray<T>, value: T) { if (!this.includes(value)) { return this; // nothing to do } // SameValueZero comparison (NaN !== NaN) - let predicate = value === value ? (item) => item !== value : (item) => item === item; + let predicate = value === value ? (item: T) => item !== value : (item: T) => item === item; return this.filter(predicate); }, }); @@ -1344,8 +1474,25 @@ const ArrayMixin = Mixin.create(Enumerable, { @uses MutableEnumerable @public */ - -const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { +interface MutableArray<T> extends EmberArray<T>, MutableEnumerable { + replace(idx: number, amt: number, objects?: readonly T[]): void; + clear(): this; + insertAt(idx: number, object: T): this; + removeAt(start: number, len?: number): this; + pushObject(obj: T): this; + pushObjects(objects: T[]): this; + popObject(): T | undefined; + shiftObject(): T | null | undefined; + unshiftObject(object: T): this; + unshiftObjects(objects: T[]): this; + reverseObjects(): this; + setObjects(object: T[]): this; + removeObject(object: T): this; + removeObjects(objects: T[]): this; + addObject(obj: T): this; + addObjects(objects: T[]): this; +} +const MutableArray = Mixin.create(EmberArray, MutableEnumerable, { /** __Required.__ You must implement this method to apply this mixin. @@ -1408,7 +1555,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - insertAt(idx, object) { + insertAt(idx: number, object: unknown) { insertAt(this, idx, object); return this; }, @@ -1434,7 +1581,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - removeAt(start, len) { + removeAt(start: number, len?: number) { return removeAt(this, start, len); }, @@ -1454,7 +1601,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return object same object passed as a param @public */ - pushObject(obj) { + pushObject<T>(this: MutableArray<T>, obj: T) { return insertAt(this, this.length, obj); }, @@ -1469,11 +1616,11 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { ``` @method pushObjects - @param {EmberArray} objects the objects to add - @return {EmberArray} receiver + @param {Array} objects the objects to add + @return {MutableArray} receiver @public */ - pushObjects(objects) { + pushObjects<T>(this: MutableArray<T>, objects: T[]) { this.replace(this.length, 0, objects); return this; }, @@ -1545,7 +1692,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return object same object passed as a param @public */ - unshiftObject(obj) { + unshiftObject<T>(this: MutableArray<T>, obj: T) { return insertAt(this, 0, obj); }, @@ -1565,7 +1712,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - unshiftObjects(objects) { + unshiftObjects<T>(this: MutableArray<T>, objects: T[]) { this.replace(0, 0, objects); return this; }, @@ -1606,7 +1753,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver with the new content @public */ - setObjects(objects) { + setObjects<T>(this: MutableArray<T>, objects: T[]) { if (objects.length === 0) { return this.clear(); } @@ -1632,7 +1779,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - removeObject(obj) { + removeObject<T>(this: MutableArray<T>, obj: T) { let loc = this.length || 0; while (--loc >= 0) { let curObject = objectAt(this, loc); @@ -1652,10 +1799,11 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - removeObjects(objects) { + removeObjects<T>(this: MutableArray<T>, objects: T[]) { beginPropertyChanges(); for (let i = objects.length - 1; i >= 0; i--) { - this.removeObject(objects[i]); + // SAFETY: Due to the loop structure we know this will always exist. + this.removeObject(objects[i]!); } endPropertyChanges(); return this; @@ -1677,7 +1825,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - addObject(obj) { + addObject<T>(this: MutableArray<T>, obj: T) { let included = this.includes(obj); if (!included) { @@ -1695,7 +1843,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @return {EmberArray} receiver @public */ - addObjects(objects) { + addObjects<T>(this: MutableArray<T>, objects: T[]) { beginPropertyChanges(); objects.forEach((obj) => this.addObject(obj)); endPropertyChanges(); @@ -1757,13 +1905,17 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, { @uses Observable @public */ +interface NativeArray<T> + extends Omit<Array<T>, 'every' | 'filter' | 'find' | 'forEach' | 'map' | 'reduce' | 'slice'>, + MutableArray<T> {} + let NativeArray = Mixin.create(MutableArray, Observable, { - objectAt(idx) { + objectAt(idx: number) { return this[idx]; }, // primitive for array support. - replace(start, deleteCount, items = EMPTY_ARRAY) { + replace(start: number, deleteCount: number, items = EMPTY_ARRAY) { assert('The third argument to replace needs to be an array.', Array.isArray(items)); replaceInNativeArray(this, start, deleteCount, items); @@ -1775,41 +1927,45 @@ let NativeArray = Mixin.create(MutableArray, Observable, { // Remove any methods implemented natively so we don't override them const ignore = ['length']; NativeArray.keys().forEach((methodName) => { - if (Array.prototype[methodName]) { + // SAFETY: It's safe to read unknown properties from an object + if ((Array.prototype as any)[methodName]) { ignore.push(methodName); } }); NativeArray = NativeArray.without(...ignore); -let A; +let A: <T>(arr?: Array<T>) => NativeArray<T>; if (ENV.EXTEND_PROTOTYPES.Array) { NativeArray.apply(Array.prototype, true); - A = function (arr) { + A = function <T>(this: unknown, arr?: Array<T>) { assert( 'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`', !(this instanceof A) ); - return arr || []; + // SAFTEY: Since we are extending prototypes all true native arrays are Ember NativeArrays + return (arr || []) as NativeArray<T>; }; } else { - A = function (arr) { + A = function <T>(this: unknown, arr?: Array<T>) { assert( 'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`', !(this instanceof A) ); - if (!arr) { - arr = []; + if (isEmberArray(arr)) { + // SAFETY: If it's a true native array and it is also an EmberArray then it should be an Ember NativeArray + return arr as NativeArray<T>; + } else { + // SAFETY: This will return an NativeArray but TS can't infer that. + return NativeArray.apply(arr ?? []) as NativeArray<T>; } - - return ArrayMixin.detect(arr) ? arr : NativeArray.apply(arr); }; } export { A, NativeArray, MutableArray }; -export default ArrayMixin; +export default EmberArray;
true
Other
emberjs
ember.js
8c6a1594b72ecb9e0f56161e08c815b76f4bb21a.json
Improve types for array internals
packages/@ember/-internals/runtime/lib/system/array_proxy.ts
@@ -16,15 +16,14 @@ import { } from '@ember/-internals/metal'; import { isObject } from '@ember/-internals/utils'; import EmberObject from './object'; -import type EmberArray from '../mixins/array'; -import { isArray, MutableArray } from '../mixins/array'; +import EmberArray, { MutableArray } from '../mixins/array'; import { assert } from '@ember/debug'; import { setCustomTagFor } from '@glimmer/manager'; import type { Tag, Revision } from '@glimmer/validator'; import { combine, consumeTag, validateTag, valueForTag, tagFor } from '@glimmer/validator'; import type { PropertyDidChange } from '@ember/-internals/metal/lib/property_events'; -function isMutable<T>(obj: EmberArray<T>): obj is MutableArray<T> { +function isMutable<T>(obj: T[] | EmberArray<T>): obj is T[] | MutableArray<T> { return Array.isArray(obj) || typeof (obj as MutableArray<T>).replace === 'function'; } @@ -110,8 +109,8 @@ function customTagForArrayProxy(proxy: object, key: string) { @public */ // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars -interface ArrayProxy<T, C extends EmberArray<T> = EmberArray<T>> extends MutableArray<T> {} -class ArrayProxy<T, C extends EmberArray<T> = EmberArray<T>> +interface ArrayProxy<T, C extends EmberArray<T> | T[] = T[]> extends MutableArray<T> {} +class ArrayProxy<T, C extends EmberArray<T> | T[] = T[]> extends EmberObject implements PropertyDidChange { @@ -212,15 +211,15 @@ class ArrayProxy<T, C extends EmberArray<T> = EmberArray<T>> @method replaceContent @param {Number} idx The starting index @param {Number} amt The number of items to remove from the content. - @param {EmberArray} objects Optional array of objects to insert. + @param {Array} objects Optional array of objects to insert. @return {void} @public */ replaceContent(idx: number, amt: number, objects?: T[]) { let content = get(this, 'content'); - assert('[BUG] Called objectAtContent without content', content); + assert('[BUG] Called replaceContent without content', content); assert('Mutating a non-mutable array is not allowed', isMutable(content)); - content.replace(idx, amt, objects); + replace<T>(content, idx, amt, objects); } // Overriding objectAt is not supported. @@ -306,8 +305,14 @@ class ArrayProxy<T, C extends EmberArray<T> = EmberArray<T>> // @ts-expect-error This check is still good for ensuring correctness assert("Can't set ArrayProxy's content to itself", arrangedContent !== this); assert( - `ArrayProxy expects an Array or ArrayProxy, but you passed ${typeof arrangedContent}`, - isArray(arrangedContent) || (arrangedContent as any).isDestroyed + `ArrayProxy expects a native Array, EmberArray, or ArrayProxy, but you passed ${typeof arrangedContent}`, + (function (arr: unknown): arr is EmberArray<unknown> { + return Array.isArray(arr) || EmberArray.detect(arr); + })(arrangedContent) + ); + assert( + 'ArrayProxy expected its contents to not be destroyed', + !(arrangedContent as any).isDestroyed ); addArrayObserver(arrangedContent, this, ARRAY_OBSERVER_MAPPING);
true
Other
emberjs
ember.js
8c6a1594b72ecb9e0f56161e08c815b76f4bb21a.json
Improve types for array internals
packages/@ember/object/lib/computed/reduce_computed_macros.ts
@@ -966,7 +966,7 @@ export function setDiff(setAProperty: string, setBProperty: string) { return emberA(); } if (!isNativeOrEmberArray(setB)) { - return emberA(setA); + return setA; } return setA.filter((x) => setB.indexOf(x) === -1);
true
Other
emberjs
ember.js
127bbf36028a0980c30be6563a054c1c262c1384.json
Correct some types for internals
packages/@ember/-internals/metal/lib/computed.ts
@@ -903,8 +903,8 @@ export function computed( } export function autoComputed( - ...config: [ComputedPropertyObj] -): ComputedDecorator | DecoratorPropertyDescriptor { + ...config: [ComputedPropertyObj | ComputedPropertyGetterFunction] +): ComputedDecorator { // SAFETY: We passed in the impl for this class return makeComputedDecorator( new AutoComputedProperty(config),
true
Other
emberjs
ember.js
127bbf36028a0980c30be6563a054c1c262c1384.json
Correct some types for internals
packages/@ember/-internals/runtime/lib/mixins/array.d.ts
@@ -26,27 +26,27 @@ interface EmberArray<T> extends Enumerable { ): NativeArray<U>; mapBy<K extends string>(key: K): NativeArray<Value<T, K>>; filter<Target>( - callback: (this: Target, item: T, index: number, arr: this) => boolean, + callback: (this: Target, item: T, index: number, arr: this) => unknown, target?: Target ): NativeArray<T>; reject<Target>( - callback: (this: Target, item: T, index: number, arr: this) => boolean, + callback: (this: Target, item: T, index: number, arr: this) => unknown, target?: Target ): NativeArray<T>; filterBy(key: string): NativeArray<T>; rejectBy(key: string): NativeArray<T>; find<Target = void>( - callback: (this: Target, item: T, index: number, arr: this) => boolean, + callback: (this: Target, item: T, index: number, arr: this) => unknown, target?: Target ): T | undefined; findBy<K extends string>(key: K, value?: Value<T, K>): T | undefined; every<Target = void>( - callback: (this: Target, item: T, index: number, arr: this) => boolean, + callback: (this: Target, item: T, index: number, arr: this) => unknown, target?: Target ): boolean; isEvery<K extends string>(key: K, value?: Value<T, K>): boolean; any<Target = void>( - callback: (this: Target, item: T, index: number, arr: this) => boolean, + callback: (this: Target, item: T, index: number, arr: this) => unknown, target?: Target ): boolean; isAny<K extends string>(key: K, value?: Value<T, K>): boolean; @@ -103,5 +103,8 @@ export function A<A>(arr: A): A extends Array<infer V> ? NativeArray<V> : Native export function A<T>(): NativeArray<T>; export function removeAt<T>(array: T[] | EmberArray<T>, start: number, len: number): EmberArray<T>; -export function uniqBy<T>(array: T[], keyOrFunc: string | ((item: T) => unknown)): T[]; +export function uniqBy<T>( + array: T[] | EmberArray<T>, + keyOrFunc: string | ((item: T) => unknown) +): T[] | EmberArray<T>; export function isArray(obj: unknown): boolean;
true
Other
emberjs
ember.js
3418c7b9a47cf9cc5fe16000d7388b81976b4601.json
Remove K function
packages/@ember/-internals/glimmer/lib/renderer.ts
@@ -86,6 +86,8 @@ export class DynamicScope implements GlimmerDynamicScope { } } +const NO_OP = () => {}; + // This wrapper logic prevents us from rerendering in case of a hard failure // during render. This prevents infinite revalidation type loops from occuring, // and ensures that errors are not swallowed by subsequent follow on failures. @@ -218,10 +220,6 @@ function loopBegin(): void { } } -function K() { - /* noop */ -} - let renderSettledDeferred: RSVP.Deferred<void> | null = null; /* Returns a promise which will resolve when rendering has settled. Settled in @@ -239,7 +237,7 @@ export function renderSettled() { // a chance to resolve (because its resolved in backburner's "end" event) if (!_getCurrentRunLoop()) { // ensure a runloop has been kicked off - _backburner.schedule('actions', null, K); + _backburner.schedule('actions', null, NO_OP); } } @@ -266,7 +264,7 @@ function loopEnd() { throw new Error('infinite rendering invalidation detected'); } loops++; - return _backburner.join(null, K); + return _backburner.join(null, NO_OP); } } loops = 0;
true
Other
emberjs
ember.js
3418c7b9a47cf9cc5fe16000d7388b81976b4601.json
Remove K function
packages/ember-testing/lib/adapters/adapter.js
@@ -1,9 +1,5 @@ import { Object as EmberObject } from '@ember/-internals/runtime'; -function K() { - return this; -} - /** @module @ember/test */ @@ -25,15 +21,15 @@ export default EmberObject.extend({ @public @method asyncStart */ - asyncStart: K, + asyncStart() {}, /** This callback will be called whenever an async operation has completed. @public @method asyncEnd */ - asyncEnd: K, + asyncEnd() {}, /** Override this method with your testing framework's false assertion.
true
Other
emberjs
ember.js
afdee50cf5c57e05f775799b5c81e3413dba1bbc.json
Remove redundant types
packages/@ember/-internals/glimmer/lib/component.ts
@@ -857,7 +857,7 @@ class Component if (!lazyEventsProcessedForComponentClass.has(proto)) { let lazyEvents = eventDispatcher.lazyEvents; - lazyEvents.forEach((mappedEventName: string | null, event: string) => { + lazyEvents.forEach((mappedEventName, event) => { if (mappedEventName !== null && typeof (this as any)[mappedEventName] === 'function') { eventDispatcher.setupHandlerForBrowserEvent(event); }
false
Other
emberjs
ember.js
474057360405daf9d1bb3d402f5742e27e76c8af.json
Add v4.5.0-beta.1 to CHANGELOG (cherry picked from commit c335315f744fe6921d0a293a48b4f1027cab0cac)
CHANGELOG.md
@@ -1,5 +1,10 @@ # Ember Changelog +### v4.5.0-beta.1 (May 2, 2022) + +- [#20052](https://github.com/emberjs/ember.js/pull/20052) / [#20055](https://github.com/emberjs/ember.js/pull/20055) [FEATURE] Add the default helper manager to implement [RFC #0756](https://github.com/emberjs/rfcs/blob/master/text/0756-helper-default-manager.md). +- [#20053](https://github.com/emberjs/ember.js/pull/20053) [FEATURE] Expose `renderSettled` from `@ember/renderer` to enable implementation of [RFC #0785](https://github.com/emberjs/rfcs/blob/master/text/0785-remove-set-get-in-tests.md). + ### v4.4.0 (May 2, 2022) - [#19882](https://github.com/emberjs/ember.js/pull/19882) / [#20005](https://github.com/emberjs/ember.js/pull/20005) [FEATURE] Implement the `unique-id` helper per [RFC #0659](https://github.com/emberjs/rfcs/blob/master/text/0659-unique-id-helper.md).
false
Other
emberjs
ember.js
d723329ee9ee2dc278ead43f2302ef01b0aa8e9e.json
Add v4.4.0 to CHANGELOG (cherry picked from commit 6ae29cade22cf3caf52e7de9aefcc937de4c1f6f)
CHANGELOG.md
@@ -1,17 +1,17 @@ # Ember Changelog -## v3.28.9 (April 19, 2022) - -- [#20028](https://github.com/emberjs/ember.js/pull/20028) Fix a memory leak in the Router Service class - -### v4.4.0-beta.1 (March 24, 2022) +### v4.4.0 (May 2, 2022) - [#19882](https://github.com/emberjs/ember.js/pull/19882) / [#20005](https://github.com/emberjs/ember.js/pull/20005) [FEATURE] Implement the `unique-id` helper per [RFC #0659](https://github.com/emberjs/rfcs/blob/master/text/0659-unique-id-helper.md). - [#19981](https://github.com/emberjs/ember.js/pull/19981) [FEATURE] Facilitate custom test setups per [RFC #0637](https://github.com/emberjs/rfcs/blob/master/text/0637-customizable-test-setups.md). - [#16879](https://github.com/emberjs/ember.js/pull/16879) [BUGFIX] isEmpty on nested objects - [#17978](https://github.com/emberjs/ember.js/pull/17978) Make hasListeners public - [#20014](https://github.com/emberjs/ember.js/pull/20014) Log `until` for deprecations +### v3.28.9 (April 19, 2022) + +- [#20028](https://github.com/emberjs/ember.js/pull/20028) Fix a memory leak in the Router Service class + ### v4.3.0 (March 21, 2022) - [#20025](https://github.com/emberjs/ember.js/pull/20025) [BUGFIX] Fix a memory leak in the Router Service class
false
Other
emberjs
ember.js
9fb35c41563d450293d991d313bd99f82b4acece.json
Convert view internals to TS
packages/@ember/-internals/glimmer/lib/component.ts
@@ -857,7 +857,7 @@ class Component if (!lazyEventsProcessedForComponentClass.has(proto)) { let lazyEvents = eventDispatcher.lazyEvents; - lazyEvents.forEach((mappedEventName: string, event: string) => { + lazyEvents.forEach((mappedEventName: string | null, event: string) => { if (mappedEventName !== null && typeof (this as any)[mappedEventName] === 'function') { eventDispatcher.setupHandlerForBrowserEvent(event); }
true
Other
emberjs
ember.js
9fb35c41563d450293d991d313bd99f82b4acece.json
Convert view internals to TS
packages/@ember/-internals/glimmer/lib/modifiers/action.ts
@@ -50,15 +50,15 @@ export let ActionHelper = { registerAction(actionState: ActionState) { let { actionId } = actionState; - (ActionManager.registeredActions as Record<string, unknown>)[actionId] = actionState; + ActionManager.registeredActions[actionId] = actionState; return actionId; }, unregisterAction(actionState: ActionState) { let { actionId } = actionState; - delete (ActionManager.registeredActions as Record<string, unknown>)[actionId]; + delete ActionManager.registeredActions[actionId]; }, };
true
Other
emberjs
ember.js
9fb35c41563d450293d991d313bd99f82b4acece.json
Convert view internals to TS
packages/@ember/-internals/views/lib/mixins/action_support.d.ts
@@ -1,8 +0,0 @@ -import Mixin from '@ember/object/mixin'; - -interface ActionSupport { - send(actionName: string, ...args: unknown[]): void; -} -declare const ActionSupport: Mixin; - -export default ActionSupport;
true