RobbieTheWagner/ember-math-helpers

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

Closed this issue · 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 perhaps something in latest Ember broke things? The types are working for us in Ember 3.28

@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.

@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?

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:

"@types/ember": "^4.0.10",
"@types/ember__object": "^4.0.11",
"@types/ember__owner": "^4.0.8",
"@types/ember__service": "^4.0.8",
"@types/ember__controller": "^4.0.11",
"@types/ember__string": "^3.16.3",
"@types/ember__template": "^4.0.5",
"@types/ember__polyfills": "^4.0.5",
"@types/ember__utils": "^4.0.6",
"@types/ember__runloop": "^4.0.8",
"@types/ember__debug": "^4.0.7",
"@types/ember__engine": "^4.0.10",
"@types/ember__application": "^4.0.10",
"@types/ember__test": "^4.0.5",
"@types/ember__array": "^4.0.9",
"@types/ember__error": "^4.0.5",
"@types/ember__component": "^4.0.21",
"@types/ember__modifier": "^4.0.8",
"@types/ember__helper": "^4.0.5",
"@types/ember__routing": "^4.0.19",

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.

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

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

We are having the following code:

export interface SubSignature {
Args: {
Positional: Array<number>;
};
Return: number;
}

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*.