Closed sidar-coolgames closed 2 years ago
I am not able to reproduce this issue. I am able to use this code with no errors building my typescript project:
import GameAnalytics, { EGAProgressionStatus } from "gameanalytics";
GameAnalytics.addProgressionEvent(EGAProgressionStatus.Complete, "world1", "level1", "phase1");
Maybe you can send me a sample project where issue is producible or describe in step how to reproduce the error.
In your example you're only accessing the enum value which works fine, but I have a custom function which needs to take a EGAProgressionStatus
value, but I can't declare the parameter with type EGAProgressionStatus
. gameanalytics.EGAProgressionStatus
doesn't point to the actual type but a variable.
the following won't work
myReportProgression(status: EGAProgressionStatus) : void
{
GameAnalytics.addProgressionEvent(status, "world1", "level1", "phase1");
}
Because EGAProgressionStatus
is not a type but a value.
OK thanks I will have a look at what goes wrong
Ok I have tried to make a fix now in the declaration file. Let me know if that helps or not. When I tested it seemed to work as described with your example.
Yes that work.
Apparently because we transform our code with webpack we have to use import * as gameanalytics from "gameanalytics";
so it becomes flowType: gameanalytics.gameanalytics.EGAResourceFlowType
. Not a problem just a fyi.
Ok good to hear
Is there any reason why EGAResourceFlowType and EGAProgressionStatus are not directly accessible from the d.ts?
We are writing some wrapper functions and need to specify the enum type for the parameter but it complains that those types are used as values. i.e.
myReportProgression(status: EGAProgressionStatus),
gives'EGAProgressionStatus' refers to a value, but is being used as a type here. Did you mean 'typeof EGAProgressionStatus'?
but if it's set to "typeof" then
GameAnalytics.addProgressionEvent(status)
failsArgument of type 'typeof EGAProgressionStatus' is not assignable to parameter of type 'EGAProgressionStatus | undefined'
Most of the module isn't accessible either ( for example I would want to check if the GA is initialized with the state object). What is the reasoning behind this?