Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions types/ember/v2/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ declare module 'ember' {
triggerAction(opts: TriggerActionOptions): boolean;
}

interface DeprecationOptions {
id: string;
until: string;
url?: string;
}

export namespace Ember {
interface FunctionPrototypeExtensions {
/**
Expand Down Expand Up @@ -2574,14 +2580,14 @@ declare module 'ember' {
*/
deprecatingAlias(
dependentKey: string,
options: { id: string; until: string }
options: DeprecationOptions
): ComputedProperty<any>;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
deprecatingAlias(
dependentKey: string,
options?: { id?: string; until?: string }
options?: Partial<DeprecationOptions>
): ComputedProperty<any>;
/**
* A computed property that returns the sum of the values
Expand Down Expand Up @@ -2977,15 +2983,15 @@ declare module 'ember' {
function deprecate(
message: string,
test: boolean,
options: { id: string; until: string }
options: DeprecationOptions
): any;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
function deprecate(
message: string,
test: boolean,
options?: { id?: string; until?: string }
options?: Partial<DeprecationOptions>
): any;
/**
* Define an assertion that will throw an exception if the condition is not met.
Expand All @@ -3012,7 +3018,7 @@ declare module 'ember' {
*/
function deprecateFunc<Func extends ((...args: any[]) => any)>(
message: string,
options: { id: string; until: string },
options: DeprecationOptions,
func: Func
): Func;
/**
Expand Down
8 changes: 8 additions & 0 deletions types/ember/v2/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ function testDeprecateFunc() {
assertType<string>(oldMethod('first', 123));
}

function testDeprecate() {
Ember.deprecate('This has been deprecated', false, {
id: 'some.id',
until: '1.0.0',
url: 'http://www.emberjs.com'
});
}

function testDefineProperty() {
const contact = {};

Expand Down
11 changes: 9 additions & 2 deletions types/ember__application/deprecations.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
// tslint:disable-next-line:strict-export-declare-modifiers
interface DeprecationOptions {
id: string;
until: string;
url?: string;
}

/**
* Display a deprecation warning with the provided message and a stack trace
* (Chrome and Firefox only).
*/
export function deprecate(
message: string,
test: boolean,
options: { id: string; until: string }
options: DeprecationOptions
): any;

/**
* Alias an old, deprecated method with its new counterpart.
*/
export function deprecateFunc<Func extends ((...args: any[]) => any)>(
message: string,
options: { id: string; until: string },
options: DeprecationOptions,
func: Func
): Func;
7 changes: 6 additions & 1 deletion types/ember__application/test/deprecations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { deprecate, deprecateFunc } from '@ember/application/deprecations';

deprecate('this is no longer advised', false, {
id: 'no-longer-advised',
until: 'v4.0'
});
deprecate('this is no longer advised', false, {
id: 'no-longer-advised',
until: 'v4.0'
until: 'v4.0',
url: 'https://emberjs.com'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's better, but if you split this call into two where one contains the url and the other doesn't, it keeps the old test while testing the new (optional) behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated it!

});
deprecate('this is no longer advised', false); // $ExpectError

Expand Down