Skip to content
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

Enhancement/strict errors #2

Merged
merged 4 commits into from
Jun 17, 2018
Merged

Conversation

andresa88
Copy link
Contributor

As of TypeScript 2.7, when strict is enabled, any class properties not initialized in the constructor will be reported as an error when accessed unless we use definite assignment assertions. So I squashed these property initialization errors. Dealt with the strict null error checks as well.

I also changed the Map-like property types from Array to Object to deal with other strict related errors. I initially wanted to switch to ES6 Map but decided to stick with Object so as to not require the Map type definition and needing to polyfill Map when targeting ES5 browsers.

Finally I updated 3 unit tests to deal with the undefined to null type changes.

@icek
Copy link
Owner

icek commented May 23, 2018

Thank you for the pull request, I will look at it by the end of this week.

@andresa88
Copy link
Contributor Author

No problem. Thanks for this awesome port. I was going to do it myself but decided to google first and stumbled on this.

@icek
Copy link
Owner

icek commented May 28, 2018

Great job, this looks very good. I will make changes in the example game and update typescript in package.json and then I will accept your PR and push everything together to this repo.

@andresa88
Copy link
Contributor Author

Awesome. I don't think I could have come up with a way to iterate through the Component fields in a Node class like you managed to do using the "keep" decorator. I learned a bit about decorators after seeing your implementation. Cool stuff! Thanks again for this.

I'm trying to use it in an OpenFL project, but I think it needs a couple more tweaks. In /dist/ash.d.ts I had to add a module declaration for "ash.ts", basically a copy of the "ash" module.

declare module 'ash.ts' {
    export { Dictionary } from 'ash/Dictionary';
    export { Signal0 } from 'ash/signals/Signal0';
    export { Signal1 } from 'ash/signals/Signal1';
    .... 
    export { ListIteratingSystem } from 'ash/tools/ListIteratingSystem';
}

And then I had to add this to ash.ts/package.json:

"types": "./dist/ash.d.ts"

This way I can import ash modules from a different project folder like so:

myproject/src/main.ts:

import { Engine, Entity } from "ash.ts";

let engine:Engine = new Engine();

Where ash.ts is installed under "myproject/node_modules/ash.ts"

@icek
Copy link
Owner

icek commented May 28, 2018

I do not quite understand how you want to use it in the Openfl project. I have not dealt with Haxe / OpenFL for almost a year, but from what I remember to use libraries written in other languages than Haxe you had to write extern files to them.
Can you now use Typescript as an input language instead of Haxe?
There is an awesome Ash port written in Haxe: https://github.com/nadako/Ash-Haxe
Maybe you should use it?

No problem with package.json entry:
"types": "./dist/ash.d.ts"
At the moment it is
"typings": "dist/ash.d.ts"
This is something that has changed in the specification. I will add this.

@icek
Copy link
Owner

icek commented May 28, 2018

Could you please try to change ash to ash.ts in these two lines:
https://github.com/icek/ash.ts/blob/master/webpack.config.js#L47
https://github.com/icek/ash.ts/blob/master/webpack.config.base.js#L24
This should generate module named ash.ts so no change in dist/ash.d.ts will be required.
Let me know if it works.

@andresa88
Copy link
Contributor Author

Yes! That worked. I ran "npm run build" and it updated the ambient module declaration names to "ash.ts".

And you're right about typings, it works just like "types", it seems they're both equivalent. Good to know!

As for OpenFL, jgranick released a npm version earlier this year, so you can now write openfl apps in typescript or javascript. I prefer at the moment the webpack + typescript + npm development environment so I'm playing around with it. I did use the haxe version of ash a while back, but now with typescript openfl, I wanted to try ash out with it and so far so good with these changes we've made.

@icek
Copy link
Owner

icek commented May 28, 2018

That's great!
Could you please open the issue about changing the package name in .d.ts file?
Starting from thursday I have a few days off from daily work so I will make all these changes.

@andresa88
Copy link
Contributor Author

Will do.

@icek icek merged commit b246b5b into icek:master Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants