ember-math-helpers icon indicating copy to clipboard operation
ember-math-helpers copied to clipboard

Namespace '"@ember/component/helper"' has no exported member 'EmptyObject'.

Open jelhan opened this issue 1 year ago • 6 comments

I run into the following type error when using ember-math-helpers with types provided by Ember natively.

node_modules/ember-math-helpers/declarations/helpers/sub.d.ts:21:50 - error TS2694: Namespace '"@ember/component/helper"' has no exported member 'EmptyObject'.

21         Named: import("@ember/component/helper").EmptyObject;
                                                    ~~~~~~~~~~

I'm using the following versions:

  • ember-math-helpers 4.0.0
  • ember-source: 5.4.0
  • typescript: 5.2.2
  • @glint/core: 1.2.1

jelhan avatar Nov 12 '23 15:11 jelhan

@jelhan perhaps something in latest Ember broke things? The types are working for us in Ember 3.28

RobbieTheWagner avatar Dec 01 '23 19:12 RobbieTheWagner

@RobbieTheWagner I'm using the types shipped with Ember 5.4. I assume you are using types from DefinitelyTyped with Ember 3.28. That may explain the difference.

jelhan avatar Dec 01 '23 22:12 jelhan

@RobbieTheWagner I'm using the types shipped with Ember 5.4. I assume you are using types from DefinitelyTyped with Ember 3.28. That may explain the difference.

Even so, this addon itself is on newer Ember. Not sure if it uses the types you are using or not though. How do you make it use them to test?

RobbieTheWagner avatar Dec 02 '23 15:12 RobbieTheWagner

Not sure if it uses the types you are using or not though.

I don't think so. At least it depends on the @types/ember* packages: https://github.com/RobbieTheWagner/ember-math-helpers/blob/a9824a8b9e2a808faf710ac27b33b2e4fadb1047/ember-math-helpers/package.json#L50-L69

How do you make it use them to test?

Please find official migration guide here: https://blog.emberjs.com/stable-typescript-types-in-ember-5-1#toc_migration-guide

I'm not sure if it's safe to assume that an addon tested against types shipped with Ember itself, will work smoothly with types from DefinitelyTyped. I'm not a Typescript expert to be honest. Not sure if there are established testing strategies.

jelhan avatar Dec 03 '23 01:12 jelhan

I don't have a computer at hand the next days. I can setup a reproduction mid December if that helps.

jelhan avatar Dec 03 '23 01:12 jelhan

It seems that this is caused by how TypeScript compiles the helper signature.

We are having the following code: https://github.com/RobbieTheWagner/ember-math-helpers/blob/bb1cebcd5f6c33ec9de427fcce2433eaefb8a743/ember-math-helpers/src/helpers/sub.ts#L3-L8

TypeScript compiles it to:

declare const _default: import("@ember/component/helper").FunctionBasedHelper<{
    Args: {
        Positional: number[];
        Named: import("@ember/component/helper").EmptyObject;
    };
    Return: number;
}>;

Please note that we don't declare the Named property ourselves at all. It seems that it is inherited from somewhere else and than inlined by TypeScript compiler. I think it is coming from @types/ember__component. Especially from this lines of code: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bd89f8e13fe2f9ad930c5255863d85daaff073d/types/ember__component/helper.d.ts#L23-L39

Sadly, this is not the first incompatibility I'm running into between @types/ember* and types published by ember-source. I don't think it can be fixed in this addon but needs to be fixed upstream in @types/ember*.

jelhan avatar Dec 13 '23 10:12 jelhan