Closed zoehneto closed 6 years ago
Lovely, thank you very much! I left a few comments, but overall looks really nice :)
Thanks for the quick review, I addressed your comments in the latest commit.
Awesome, thanks!
Just out of curiosity - have you used TypeWiz on any of your projects?
What is not yet covered by this PR (and was also not covered in #27) is how to roll out these changes to typewiz-node
and typewiz-webpack
. I personally don't use either since I bundle with rollup and then test the bundle but this should be considered going forward.
Just saw your comment, I have experimentally added typewiz to rtf.js where I use a custom script for instrumentation.
Very interesting - so in this case, you are basically writing an instrumented copy of your source code to the build
directory, and then the tests run using the instrumented source code, right?
I couldn't find where you told the bundle / test steps to read the source files from the build
directory though, can you please point me?
It works as follows:
typewiz-instrument.js
instruments the files using the typewiz api (the key here is to pass the original filenames in the source directory to the instrumenter), compiles the individual files using the typescript api and then writes the files to the build directory.npm run bundle
is invoked which creates three UMD / ES5 bundles in the dist
directory based on the instrumented code from build
npm run test
which runs the script test/test-rtfjs.js
(this script executes a test for every directory under test/test-files
and applies the collected types after all tests are finished). To execute the individual tests test/utils.js
is used which converts rtf files to html. Since rtf.js
requires a browser to run (because of some of the libraries it's built on) the actual test is executed using JSDOM which loads the scripts from dist
(line 30 - 32) and has to be passed $_$twiz
(line 105).Got it, thanks!
I'm currently helping migrate immer to TS using typewiz, and they are also using rollup for their build. In their case, I used rollup-plugin-typescript2. In your build, you are running TypeScript as a separate compile step. Is there any reason for preferring running TypeScript separately and not as part of rollup?
In rtf.js we build three separate bundles (for rtf.js, emf.js and wmf.js) but building rtf.js requires building the other two with tsc in the same step (because of some import tricks it uses) so if it used the rollup plugin emf.js and wmf.js would be built twice.
And how useful have you found TypeWiz so far for rtf.js?
Sadly I found your blog post too late. A month ago it was just three plain ES5 files with around 9000 lines of code and then I did the entire conversion by hand and added all the typings :(
I hear you... I did the same with several projects before coming up with TypeWiz. But the future will be brighter :)
Released as part of 0.7.0
Optionally applies
this
types to functions. Fixes #33 .