Merge pull request #33522 from mike-north/fix-deprecate

[@types/ember] Add url property to deprecation options
This commit is contained in:
Nathan Shively-Sanders
2019-03-07 16:22:53 -08:00
committed by GitHub
5 changed files with 37 additions and 11 deletions
+12 -6
View File
@@ -12,7 +12,6 @@
// TypeScript Version: 2.4
/// <reference types="jquery" />
/// <reference types="handlebars" />
declare module 'ember' {
// Capitalization is intentional: this makes it much easier to re-export RSVP on
@@ -274,6 +273,12 @@ declare module 'ember' {
triggerAction(opts: TriggerActionOptions): boolean;
}
interface DeprecationOptions {
id: string;
until: string;
url?: string;
}
export namespace Ember {
interface FunctionPrototypeExtensions {
/**
@@ -2415,6 +2420,7 @@ declare module 'ember' {
function print(ast: any): void;
const logger: typeof Ember.Logger;
function log(level: string, str: string): void;
function registerHelper(name: string, helper: any): void;
}
namespace String {
function camelize(str: string): string;
@@ -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
@@ -2977,7 +2983,7 @@ 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
@@ -2985,7 +2991,7 @@ declare module 'ember' {
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.
@@ -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;
/**
+2 -2
View File
@@ -92,10 +92,10 @@ App.userController = Ember.Object.create({
}),
});
Handlebars.registerHelper(
Ember.Handlebars.registerHelper(
'highlight',
(property: string, options: any) =>
new Handlebars.SafeString('<span class="highlight">' + 'some value' + '</span>')
new Ember.Handlebars.SafeString('<span class="highlight">' + 'some value' + '</span>')
);
const coolView = App.CoolView.create();
+8
View File
@@ -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 = {};
+9 -2
View File
@@ -1,3 +1,10 @@
// 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).
@@ -5,7 +12,7 @@
export function deprecate(
message: string,
test: boolean,
options: { id: string; until: string }
options: DeprecationOptions
): any;
/**
@@ -13,6 +20,6 @@ export function deprecate(
*/
export function deprecateFunc<Func extends ((...args: any[]) => any)>(
message: string,
options: { id: string; until: string },
options: DeprecationOptions,
func: Func
): Func;
@@ -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'
});
deprecate('this is no longer advised', false); // $ExpectError