Merge pull request #29196 from mike-north/ember-remove-private

[ember] Remove some deprecated and private types
This commit is contained in:
Andrew Casey 2018-09-25 17:57:03 -07:00 committed by GitHub
commit 255de86d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 96 deletions

View File

@ -205,21 +205,6 @@ export namespace Ember {
w(): string[];
}
/**
* Connects the properties of two objects so that whenever the value of one property changes,
* the other property will be changed also.
*
* @deprecated https://emberjs.com/deprecations/v2.x#toc_ember-binding
*/
class Binding {
constructor(toPath: string, fromPath: string);
connect(obj: any): Binding;
copy(): Binding;
disconnect(): Binding;
from(path: string): Binding;
to(path: string | string[]): Binding;
toString(): string;
}
/**
* Implements some standard methods for comparing objects. Add this mixin to
* any class you create that can compare its instances.
@ -263,28 +248,7 @@ export namespace Ember {
const Error: EmberError;
const Evented: typeof EmberObjectEventedNs.default;
/**
* The `Ember.Freezable` mixin implements some basic methods for marking an
* object as frozen. Once an object is frozen it should be read only. No changes
* may be made the internal state of the object.
* @deprecated Use `Object.freeze` instead.
*/
interface Freezable {
freeze(): Freezable;
isFrozen: boolean;
}
const Freezable: EmberMixin<Freezable>;
/**
* The purpose of the Ember Instrumentation module is
* to provide efficient, general-purpose instrumentation
* for Ember.
*/
const Instrumentation: {
instrument(name: string, payload: any, callback: (...args: any[]) => any, binding: any): void;
reset(): void;
subscribe(pattern: string, object: any): void;
unsubscribe(subscriber: any): void;
};
/**
* Inside Ember-Metal, simply uses the methods from `imports.console`.
* Override this to provide more robust logging functionality.
@ -364,19 +328,7 @@ export namespace Ember {
}
class Service extends Object {}
interface Transition {
/**
* Aborts the Transition. Note you can also implicitly abort a transition
* by initiating another transition while a previous one is underway.
*/
abort(): Transition;
/**
* Retries a previously-aborted transition (making sure to abort the
* transition if it's still active). Returns a new transition that
* represents the new attempt to transition.
*/
retry(): Transition;
}
interface ViewTargetActionSupport {
target: any;
actionContext: any;
@ -526,12 +478,6 @@ export namespace Ember {
const runInDebug: typeof EmberDebugNs.runInDebug;
const warn: typeof EmberDebugNs.warn;
/**
* Global helper method to create a new binding. Just pass the root object
* along with a `to` and `from` path to create and connect the binding.
* @deprecated https://emberjs.com/deprecations/v2.x#toc_ember-binding
*/
function bind(obj: {}, to: string, from: string): Binding;
const cacheFor: typeof EmberObjectInternalsNs.cacheFor;
const addListener: typeof EmberObjectEventsNs.addListener;
const removeListener: typeof EmberObjectEventsNs.removeListener;
@ -568,11 +514,6 @@ export namespace Ember {
* @deprecated Use Object.assign
*/
const assign: typeof EmberPolyfillsNs.assign;
/**
* Polyfill for Object.create
* @deprecated Use Object.create
*/
function create(o: object | null): any;
/**
* Polyfill for Object.keys
* @deprecated Use Object.keys
@ -588,11 +529,6 @@ export namespace Ember {
* and reporting code.
*/
function onerror(error: Error): void;
/**
* An empty function useful for some operations. Always returns `this`.
* @deprecated https://emberjs.com/deprecations/v2.x/#toc_code-ember-k-code
*/
function K<This>(this: This): This;
/**
* The semantic version
*/
@ -608,13 +544,6 @@ export namespace Ember {
*/
const testing: boolean;
const instrument: typeof Instrumentation.instrument;
const reset: typeof Instrumentation.reset;
const subscribe: typeof Instrumentation.subscribe;
const unsubscribe: typeof Instrumentation.unsubscribe;
const expandProperties: typeof EmberObjectComputedNs.expandProperties;
}

View File

@ -275,3 +275,22 @@ Ember.String.isHTMLSafe('foo'); // $ExpectType boolean
// Ember.Test
Ember.Test.checkWaiters(); // $ExpectType boolean
// checkWaiters
/**
* == REMOVED FEATURES ==
* These are deprecated and/or private things that have been removed from the
* Ember.* namespace. These tests asserts that the types of these things
* stay gone
*/
Ember.bind; // $ExpectError
Ember.deprecate('foo', 'bar'); // $ExpectError
Ember.K; // $ExpectError
Ember.Binding; // $ExpectError
Ember.Transition; // $ExpectError
Ember.create; // $ExpectError
Ember.reset; // $ExpectError
Ember.unsubscribe; // $ExpectError
Ember.subscribe; // $ExpectError
Ember.instrument; // $ExpectError
Ember.Instrumentation; // $ExpectError

View File

@ -2,6 +2,10 @@ import Route from '@ember/routing/route';
import Object from '@ember/object';
import Array from '@ember/array';
import Ember from 'ember'; // currently needed for Transition
import Transition from '@ember/routing/-private/transition';
// Ensure that Ember.Transition is private
Ember.Transition; // $ExpectError
interface Post extends Ember.Object {
title: string;
@ -10,13 +14,13 @@ interface Post extends Ember.Object {
interface Posts extends Array<Post> {}
Route.extend({
beforeModel(transition: Ember.Transition) {
beforeModel(transition: Transition) {
this.transitionTo('someOtherRoute');
},
});
Route.extend({
afterModel(posts: Posts, transition: Ember.Transition) {
afterModel(posts: Posts, transition: Transition) {
if (posts.length === 1) {
this.transitionTo('post.show', posts.firstObject);
}

View File

@ -1,7 +1,8 @@
import Ember from 'ember';
import Transition from '@ember/routing/-private/transition';
Ember.Route.extend({
beforeModel(transition: Ember.Transition) {
beforeModel(transition: Transition) {
if (new Date() > new Date('January 1, 1980')) {
alert('Sorry, you need a time machine to enter this route.');
transition.abort();
@ -10,7 +11,7 @@ Ember.Route.extend({
});
Ember.Controller.extend({
previousTransition: <Ember.Transition | null> null,
previousTransition: <Transition | null> null,
actions: {
login() {

View File

@ -8,23 +8,6 @@ export function deprecate(
options: { id: string; until: string }
): any;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
export function deprecate(
message: string,
test: boolean,
options?: { id?: string; until?: string }
): any;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
export function deprecateFunc<Func extends ((...args: any[]) => any)>(
message: string,
func: Func
): Func;
/**
* Alias an old, deprecated method with its new counterpart.
*/

View File

@ -4,9 +4,9 @@ deprecate('this is no longer advised', false, {
id: 'no-longer-advised',
until: 'v4.0'
});
deprecate('this is no longer advised', false);
deprecate('this is no longer advised', false); // $ExpectError
deprecateFunc('this is no longer advised', () => {});
deprecateFunc('this is no longer advised', () => {}); // $ExpectError
deprecateFunc(
'this is no longer advised',
{ id: 'no-longer-do-this', until: 'v4.0' },