From 0bea293eaebe5b36440d0164d84b892f9ee69c66 Mon Sep 17 00:00:00 2001 From: Mike North Date: Tue, 25 Sep 2018 15:50:48 -0700 Subject: [PATCH] [ember] remove deprecated and private types Fixes https://github.com/typed-ember/ember-cli-typescript/issues/315 --- types/ember/index.d.ts | 75 +------------------ types/ember/test/ember-module-tests.ts | 19 +++++ types/ember/test/route.ts | 8 +- types/ember/test/transition.ts | 5 +- types/ember__application/deprecations.d.ts | 17 ----- types/ember__application/test/deprecations.ts | 4 +- 6 files changed, 32 insertions(+), 96 deletions(-) diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index ff7b678048..4e7ec4f74f 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -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; - /** - * 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; /** * 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; } diff --git a/types/ember/test/ember-module-tests.ts b/types/ember/test/ember-module-tests.ts index ed90fe42ef..5935578d3e 100644 --- a/types/ember/test/ember-module-tests.ts +++ b/types/ember/test/ember-module-tests.ts @@ -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 diff --git a/types/ember/test/route.ts b/types/ember/test/route.ts index 2256ee3561..f1ca853267 100755 --- a/types/ember/test/route.ts +++ b/types/ember/test/route.ts @@ -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 {} 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); } diff --git a/types/ember/test/transition.ts b/types/ember/test/transition.ts index 47d171e250..f06ee8865e 100755 --- a/types/ember/test/transition.ts +++ b/types/ember/test/transition.ts @@ -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: null, + previousTransition: null, actions: { login() { diff --git a/types/ember__application/deprecations.d.ts b/types/ember__application/deprecations.d.ts index a74babd084..8509e2f69d 100644 --- a/types/ember__application/deprecations.d.ts +++ b/types/ember__application/deprecations.d.ts @@ -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 any)>( - message: string, - func: Func -): Func; - /** * Alias an old, deprecated method with its new counterpart. */ diff --git a/types/ember__application/test/deprecations.ts b/types/ember__application/test/deprecations.ts index 12639ad0b5..30d1e8a075 100644 --- a/types/ember__application/test/deprecations.ts +++ b/types/ember__application/test/deprecations.ts @@ -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' },