The Screepers/Typescript team have been working on a new version of the Typescript Typings and the Typescript starter for Screeps.
We’ve made quite a few improvements to both which should improve your Typescript experience.
Screeps Typescript Definitions Version 2
The typings have been given some overloads and generic typings to remove the need to type the output of most functions.
The main example of this is in the find functions. With the old system, you had to type the output e.g.
With the new system, the FIND_* constant you use determines the output as we know that find(FIND_HOSTILE_CREEPS) must return an array of creeps. This typing is also passed to the filter functions arguments which saves you typing that as well.
Some of the constants have had stricter typings applied that guard against using RESOURCE_ENERGY in boost lists etc…
Internally the typings have been restructured so that we will be able to publish them as @types/screeps on npm in the future.
There are a load of tests in the repository now which ensure that the typings apply as expected and demo code is valid.
For a complete list of changes see the change log in the repo.
Screeps Typescript Starter Version 3
The typescript starter needed a lot of work. We felt it was too opinionated and was making too many decisions for you regarding AI design.
The new version does away with all this and only provides the code to use the source maps that get generated by Typescript. This lets you spend your time building your AI instead of learning how to use the starter.
We have swapped the bundler from Webpack to Rollup. Rollup is easier to configure and can be set up to do everything needed for Screeps. Running rollup -c –dest <server> will:
- Clean the target directory.
- Resolve all dependencies.
- Compile your Typescript.
- Translate your source maps so they can be read in Screeps.
- Upload your code to Screeps.
There isn’t much more to say really. By design, there is a lack of opinion in the starter and not much to write about here.
The documentation has been updated and is hosted on Gitbook here.
Help, Support & Contributing
Myself and the rest of the Typescript team can normally be reached in #typescript on Slack or through the issues on the Github repositories.
Both the typings and starter are open source, if you have any ideas for improvements don’t hesitate to open a PR or Issue on Github.