Skip to content

Commit

Permalink
Merge pull request emberjs#19947 from wagenet/more-type-tests
Browse files Browse the repository at this point in the history
More type tests
  • Loading branch information
chriskrycho authored and nevilm-lt committed Apr 22, 2022
1 parent fb2fc3b commit 6fc5174
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions packages/@ember/helper/type-tests/invoke-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ class PlusOne extends Helper {
}
}

class PlusOneComponent extends Component {
declare number: number;

export default class PlusOneComponent extends Component {
plusOne = invokeHelper(this, PlusOne, () => {
return {
positional: [this.number],
positional: [this.args.number],
};
});

Expand All @@ -27,6 +25,6 @@ class PlusOneComponent extends Component {
}
}

let component = PlusOneComponent.create();
let component = new PlusOneComponent();

expectTypeOf(component.plusOne).toEqualTypeOf<Cache<unknown>>();
9 changes: 4 additions & 5 deletions packages/@ember/helper/type-tests/set-helper-manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { HelperFactory, HelperFunction, SimpleHelper } from '@ember/-internals/glimmer/lib/helper';
import { getDebugName } from '@ember/-internals/utils';
import { capabilities, setHelperManager } from '@ember/helper';
import { Arguments, Dict, HelperManager } from '@glimmer/interfaces';
import { Arguments, HelperManager } from '@glimmer/interfaces';
import { expectTypeOf } from 'expect-type';

class Wrapper<T = unknown, P extends unknown[] = unknown[], N extends Dict<unknown> = Dict<unknown>>
implements HelperFactory<SimpleHelper<T, P, N>> {
class Wrapper implements HelperFactory<SimpleHelper> {
isHelperFactory: true = true;

constructor(public compute: HelperFunction<T, P, N>) {}
constructor(public compute: HelperFunction) {}

create() {
// needs new instance or will leak containers
Expand Down Expand Up @@ -42,7 +41,7 @@ export const SIMPLE_CLASSIC_HELPER_MANAGER = new SimpleClassicHelperManager();

expectTypeOf(
setHelperManager(() => SIMPLE_CLASSIC_HELPER_MANAGER, Wrapper.prototype)
).toEqualTypeOf<Wrapper<any, any, any>>();
).toEqualTypeOf<Wrapper>();

// @ts-expect-error invalid factory
setHelperManager(1, Wrapper.prototype);
Expand Down

0 comments on commit 6fc5174

Please sign in to comment.