mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Re-type helper from @ember/component/helper (#24986)
* Re-type `helper` from @ember/component/helper Previous typing caused an error about using private name `Ember.Helper` when generating declaration files. Fortunately, the previous typings were incorrect anyway, so we can remove the reference to `Ember.Helper` and thus fix the issue. Relevant links: * https://github.com/Microsoft/TypeScript/issues/5711 * https://github.com/Microsoft/TypeScript/issues/6307 * https://www.emberjs.com/api/ember/2.18/functions/@ember%2Fcomponent%2Fhelper/helper * https://github.com/emberjs/ember.js/blob/v2.18.2/packages/ember-glimmer/lib/helper.ts#L120 * Add test for `helper` from @ember/component/helper
This commit is contained in:
parent
2ea7986e94
commit
ca3bf7f06d
15
types/ember/index.d.ts
vendored
15
types/ember/index.d.ts
vendored
@ -3442,7 +3442,20 @@ declare module '@ember/component/checkbox' {
|
||||
declare module '@ember/component/helper' {
|
||||
import Ember from 'ember';
|
||||
export default class Helper extends Ember.Helper { }
|
||||
export const helper: typeof Ember.Helper.helper;
|
||||
/**
|
||||
* In many cases, the ceremony of a full `Helper` class is not required.
|
||||
* The `helper` method create pure-function helpers without instances. For
|
||||
* example:
|
||||
* ```app/helpers/format-currency.js
|
||||
* import { helper } from '@ember/component/helper';
|
||||
* export default helper(function(params, hash) {
|
||||
* let cents = params[0];
|
||||
* let currency = hash.currency;
|
||||
* return `${currency}${cents * 0.01}`;
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function helper(helperFn: (params: any[], hash?: any) => string): any;
|
||||
}
|
||||
|
||||
declare module '@ember/component/text-area' {
|
||||
|
||||
@ -25,3 +25,11 @@ const CurrentUserEmailHelper = Ember.Helper.extend({
|
||||
.get('email');
|
||||
},
|
||||
});
|
||||
|
||||
import { helper } from '@ember/component/helper';
|
||||
|
||||
function typedHelp(/*params, hash*/) {
|
||||
return 'my type of help';
|
||||
}
|
||||
|
||||
export default helper(typedHelp);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user