-
Notifications
You must be signed in to change notification settings - Fork 261
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
auto generate ts file? #97
Conversation
this uses the tsd-jsdoc npm package https://www.npmjs.com/package/tsd-jsdoc it gets a few errors and no idea how close the types are. Maybe someone more familar with typescript can take a look? checked in the generated types here You can run it with npm install ./node_modules/.bin/grunt jsdoc:ts
/** comment */ was being confused as a docstring and resulting in TS declaration pollution
use npm run buildts to re-run the ts generator and apply the script
Fixes this typo in docs and in the "mungets" task: WebGLContextCreationAttirbutes => WebGLContextCreationAttributes
All fields are optional but lacked the [default brackets] that would let grunt know about this when outputting the TypeScript definitions
These functions were documented as accepting a "subdivisionsThick" argument after "subdivisionsDown" but before "startOffset", though the function does not in fact accept such an argument. Error was revealed by WIP TypeScript test.
"npm run test" will now run both the pre-existing "js" tests as well as the new "ts" test. Use "npm run testjs" to run only the earlier tests. Borrows a handful of lines from code in the examples/ directory. It doesn't need to do anything interesting, it just needs to successfully compile. The TS test is not very thorough at this point, but it's a very solid start imo.
This is also probably the source of the build failure in commit 0e66391
Remove "types.d.ts" Add "twgl-full.d.ts" and "twgl.d.ts"
Previously in the global scope (e.g. twgl.Vec3) and now in module scope (e.g. twgl.v3.Vec3)
because I can
Re #50 (comment): I looked at the examples and didn't actually understand what the purpose of them actually was or how they were meant to run. I'd suggest removing the TypeScript-related examples for the time being if you are having trouble with them, and maybe adding functioning TS-specific examples later on. |
I can remove it but I can ship something I can't verify works. As it is now
I have zero proof it works
|
Zero proof, do you mean the definitions? If so, that's what The only way to verify through tests that no more such errors exist is to write TypeScript code utilizing every type and function in twgl. Which is an honorable goal, but a terrible prerequisite for just getting out something that works and can be maintained, since there doesn't seem to be anything like this out there yet. It is not actually important to run any JavaScript to verify that the definitions are correct. TypeScript does not change language behavior from JavaScript; it only turns certain errors that would normally be runtime errors into compile-time errors - i.e. they happen when you run |
Think of TypeScript as a complicated linter. The *.d.ts files are the linter config, and Your reference file should go through the linter without any errors. If there are any errors, then your linter config isn't right. If there are no errors, then the linter config matches up to what you expected. Executing code that is validated by the linter does not actually say anything about the correctness of the linter config. Same deal with TypeScript. Executing the output of |
This is not a real PR. It's just to allow you to take a look. See #89
this uses the tsd-jsdoc npm package
https://www.npmjs.com/package/tsd-jsdoc
it gets a few errors and no idea how close the types
are. Maybe someone more familar with typescript can take a look?
checked in the generated types here
You can run it with