-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions not in TypeScript definition files #60
Comments
Thanks for pointing this out! I'm getting a bit more comfortable with TS now, so should be able to review your PR and get it merged ASAP (it might have to wait till after the festive season unfortunately). Thanks again for your contribution! |
On a similar front, I am trying to come up with ways to deal with the Hopefully yourself or someone who knows TS better than I can provide a good solution. |
I see - as in you have written a renderer component and you want to add type safety to the props? Are you able to use Otherwise, I imagine the challenge will be to overcome the dynamic nature of the |
Also, just wondering where the TS compiler complains? Would something like this suffice: <GameEngine entities={{ player: { x: 0, y: 0, renderer: <PlayerRenderer x={0} y={0} /> }}} /> ... Or this form, which should also work: <GameEngine entities={{ player: { x: 0, y: 0, renderer: PlayerRenderer }}} /> |
I'll try them both! The first one doesn't feel good having the values entered twice but if the second one works, that is ideal! Make sure to update the typedefs to allow |
Using the second option worked perfectly. No issues with the TS-linter. Thanks heaps for the help! Now I'm just trying to come up with ways to be able to make TS recognise the entities object to have that requirement. I'm gonna have a look and might update my pull request if I work it out. I tried this but it didn't catch an incorrect value for interface GameEngineEntities {
[key:string | number]: {
[key:string]: any,
renderer?: JSX.Element | React.Component,
}
}
export interface GameEngineProperties {
systems?: any[];
entities?: GameEngineEntities | Promise<any>;
renderer?: any;
touchProcessor?: any;
timer?: DefaultTimer | any;
running?: boolean;
onEvent?: any;
style?: StyleProp<ViewStyle>;
children?: React.ReactNode;
} Not sure what to try next. |
Awesome @SimpleProgrammingAU, I took a quick look at the PR and it looks really solid. Huge thanks. I'll be 100% back online next week - I'll merge it in then. |
I haven't checked the other classes, but GameEngine.js does not appear to have its functions referenced in react-native-game-enging.d.ts:
Should
GameEngine
not be:Or something similar to?
Is this an issue for other classes?
The text was updated successfully, but these errors were encountered: