-
Notifications
You must be signed in to change notification settings - Fork 5
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 static typing #39
base: master
Are you sure you want to change the base?
Conversation
I noticed some of the types can be further narrowed down to a smaller subset, increasing the quality of the types so I would wait to merge this one right now. I'll further improve the types this week. |
@timdp This PR is ready to be reviewed again. I added static typing to all the src files, and also the tests. Added extra tests to cover the newly added methods and added a few typing fixes for our tests. For every property, I checked the VAST 3 and 4 xsd and usage in the iab-vast-parser to find out if it should be a maybe type or not. Things that we maybe still could add in this PR:
|
If this is merged, then I'll extend the codebase so the |
Definitely not against this. The main reason why we've been putting it off is because subclassing
The spec defines it though. I kind of like to have it available as a concept, even if it's not immediately useful.
Yeah, I've been wondering what to do with the constructor vs. properties in general. I wouldn't be against passing a required options object into every constructor, as long as we also bump the major version, of course. But maybe all of these things belong in separate PRs. Before we merge this one, I just want to be absolutely sure that it's compatible with all our closed-source code (which I won't describe in detail because this discussion is public 😉). |
Jup, all makes sense. |
Ready for review again. Added support for shippable flow type definitions using flow-copy-source and added links between VAST and Wrappers which enable easy VAST tree walking. |
|
||
gulp.task('watch', () => gulp.watch('src/**/*', ['build'])) | ||
|
||
gulp.task('doc:clean', () => del('docs')) | ||
gulp.task('flow', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this async
the only reason why you added stage-3 and the runtime transform, or is there another transitive dependency somewhere? If not, I'd just leave out the async
because the end result will be the same. Also, maybe we want to drop Gulp altogether in favor of npm scripts?
`docs` directory. | ||
|
||
Additionally, feel free to look at the source code. We recommend starting with | ||
`src/index.js`, which should export all the classes you need. | ||
|
||
## Typing | ||
|
||
All APIs are statically typed using (flow)[https://flow.org]. Type checking is automatically performed when running `npm test`. You can also run type checking only by using the command `npm run flow`. Static typing adds an additional layer of defense against errors and can also improve the development experience by enabling autocompletion. For (atom.io)[https://atom.io], we recommend (Flow-IDE)[https://atom.io/packages/flow-ide]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave out the last two sentences and keep the readme lean and mean. It's not our job to educate people on static typing or to impose an editor.
@@ -22,12 +22,16 @@ const vast = new VAST() | |||
|
|||
Automatically generated API documentation can be found on | |||
[GitHub Pages](https://zentrick.github.io/iab-vast-model/). You can also | |||
open `docs/index.html` in a Web browser. Running `gulp doc` will (re)build the | |||
open `docs/index.html` in a Web browser. Running `npm run doc` will (re)build the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not something to discuss under this PR, but I wonder why we have the docs on master rather than a separate gh-pages branch. There's quite a bit of static stuff here.
src/core/vast.js
Outdated
* This will check if this VAST was wrapped and check if additional VAST | ||
* wrappers should be loaded. | ||
*/ | ||
followAdditionalWrappers (): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why this isn't a getter?
Add static typing using flow + newly generated docs.