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

Add some overloads #14

Merged
merged 8 commits into from Nov 14, 2017

Conversation

Projects
None yet
2 participants
@Arcath
Contributor

Arcath commented Nov 9, 2017

Overloads some of the functions to remove the need to type the output.

With the current system, you had to type the output of some functions e.g.

room.find<Creep>(FIND_MY_CREEPS) // Has the type Creep[]

But come along later and change the find to something else

room.find<Creep>(FIND_MY_SPAWNS) // Still has the type Creep[]

Overloads let us change the output if the input has various types

room.find(FIND_MY_CREEPS) // Creep[]
room.find(FIND_MY_SPAWNS) // StructureSpawn[]

The old method is still supported and is there for anything that doesn't match the overloads.

There are more methods that could be overloaded so please don't pull this yet.

Arcath added some commits Nov 9, 2017

@Arcath

This comment has been minimized.

Contributor

Arcath commented Nov 9, 2017

The last commit adds a test command that should let us know when things get broken.

npm test runs:

  1. npm run compile
  2. npm run lint
  3. npm run compile-test

If the lint fails or either typescript compiles fail the tests will fail. @resir014 You can enable TravisCI after this PR is pulled to get automated testing up and running if you think its worth it.

Arcath added some commits Nov 9, 2017

@Arcath

This comment has been minimized.

Contributor

Arcath commented Nov 13, 2017

There's a little issue with jsdoc to fix now then its good to do.

the documentation only applies to the first overload, leaving the rest un documented.

@resir014

This comment has been minimized.

Member

resir014 commented Nov 13, 2017

@Arcath

This comment has been minimized.

Contributor

Arcath commented Nov 13, 2017

@resir014 It should be good to pull now. Might want to test it against your own AI first but it should be good to go.

@Arcath

This comment has been minimized.

Contributor

Arcath commented Nov 13, 2017

Some discussion on slack has made some overloading un needed. I'm working on it now.

@Arcath

This comment has been minimized.

Contributor

Arcath commented Nov 13, 2017

The latest commit actually removes most of my overloads in favour of some pretty crafty generic typing.

I'm not sure how backwards compatible this code is now.

@resir014

This comment has been minimized.

Member

resir014 commented Nov 13, 2017

@Arcath Hm, okay. I'll take a look at this tomorrow and test against my own code if possible.

I'll probably be on Slack tomorrow to discuss whether or not we'll do a major version bump.

@Arcath Arcath changed the base branch from master to 2.0.0 Nov 14, 2017

@resir014 resir014 merged commit 71fbc3a into screepers:2.0.0 Nov 14, 2017

@resir014 resir014 referenced this pull request Nov 14, 2017

Merged

v2.0.0 #16

7 of 7 tasks complete

@Arcath Arcath deleted the Arcath:overloads branch Nov 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment