static type checking (js + jsdoc)
Closed this issue · 1 comments
art-in commented
From v2.3 (27.04.17) typescript
now supports type checking .js
files.
And it already can gather type definitions from jsdoc
annotations.
https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files
https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript
replace runtime type/param checks with static checks:
-
src/
-
test/
- (params)
typeof
/instanceof
param checks - (params)
required-params
(forked to #65) - (params)
PropTypes
(with@typedef Props
) (forked to #66) -
guard-object-props
- webpack
--watch
mode (gulpbuild:watch
,test:watch
) - webpack normal mode (gulp
build
,test
) - add separate gulp task to check types (
test:static:types
) - code editor highlights
- no unnecessary
@ts-ignore
/@ts-nocheck
-
gotchas.static-typing.md
art-in commented
added gotchas/typescript.md to track history of typescript
usage
summary:
typescript
has bugs and unsupported syntax features (not much, but little pain)typescript
allows to type cover surprisingly complex cases (eg. dynamic generics inconnect.d.ts
)jsdoc
support intypescript
is bad (pain)- complex types would be hard or impossible to define in
jsdoc
(need.d.ts
anyway) - due to lack of
jsdoc
support, writingtypescript
directly - now looks less bad choice than before - majority of important code places is type covered, but there is still a lot of implicit
any
's (needs work) - static checking helped to find 2 hidden bugs that were hard to find in run-time
- adding static type checking for existing project is pain at start, but worth it in long-run