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

Add some typescript type definitions #113

Merged
merged 14 commits into from
Jun 21, 2020

Conversation

Jarred-Sumner
Copy link
Contributor

The majority of this was auto-generated by running the following command:

npx typescript --build tsconfig.json

Then I went through and converted some of the any to a more specific type.

These are not exhaustive types, but it makes VSCode autocomplete much better.

Examples:
image
image
image

Before this, it wouldn't show me inline autocomplete for anything in noa and I had to check the API.md docs a lot

Might be nice to remove all the definitions for noa in the classes and then anything prefixed with an _. I sometimes use the _ functions though.

fenomas and others added 14 commits March 12, 2018 18:14
* develop: (39 commits)
  Add samples to readme
  Bump version number
  Update both demos to BJS 4.0.3
  Turn on the `debug` option in both demos
  Add license file and comment block
  Belatedly add `noa.version` string Add global `noa` reference in test apps
  Catch meshing error that can trigger if client code twiddles certain    voxel data between chunk creation and first mesh
  Increment webpack-dev-server to fix warning message Typos
  Generate a package-lock.json and unignore it
  Support development on Windows machines
  Expose `noa._constants`, and make `noa.addBlock` return the assigned ID
  Tweaks - remove some unused code, fix a few misc types
  Update dependency
  Update ECS dependency for bugfix
  Debounce how often babylon engine `resize` gets called
  Add update log for v0.25.0, and note about working in develop branch
  Fix outdated stuff in readme
  Remove `markdox` dependency, and doc generation script (that wasn't being used)
  Rebuild demos in newest webpack
  Updating dependencies, webpack3 -> webpack4
  ...
* develop:
  Rebuild demos
  Log version, and add `silent` option
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](mysticatea/eslint-utils@v1.3.1...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
…slint-utils-1.4.3

Bump eslint-utils from 1.3.1 to 1.4.3
@fenomas
Copy link
Owner

fenomas commented May 29, 2020

Hi, this looks really useful! Way back in the day I used to get full autocomplete suggestions like this from VSCode even without typings, but it stopped working at some point and would be great to get back. Let me take this for a spin in my own env and check that I get the same results.

BTW: I generally keep all new dev in the #develop branch, so I'll edit this PR to base against that. Never tried changing the base of a PR before; hopefully it won't mess things up.

@fenomas fenomas changed the base branch from master to develop May 29, 2020 04:42
@Jarred-Sumner
Copy link
Contributor Author

Jarred-Sumner commented May 29, 2020 via email

@fenomas
Copy link
Owner

fenomas commented May 29, 2020

Yeah, we're in agreement. Getting good code hints is definitely worth adding a build step, but while somebody could certainly add manual annotations to say that e.g. ents.getPhysicsBody returns such and such a signature, I think it's the nature of the beast that the ECS is going to prevent automated tools from finding that signature automatically. Unless, say, there's a TS-specific way to declare such things in a function's jsdoc comment, or similar? As I'm not currently using TS I'm hazy on the details.

As for the mesher, yeah it should be possible in principle, but it's hairy (since there are already a lot of async steps in that process), and it's not obvious that it would wind up being a performance win. (Assuming the perf issue you were seeing with array merges is fixed, I mean.) So for those reasons I've been figuring it's best for meshing to stay synchronous for now.

@fenomas
Copy link
Owner

fenomas commented Jun 21, 2020

Sorry for the delay on this, for some reason I can't seem to get the nice code hints to show up in my local environment but I'll go ahead and merge this on the assumption that it's working somewhere, maybe it can be fixed later.

@fenomas fenomas merged commit 38e661c into fenomas:develop Jun 21, 2020
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