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

static type checking (js + jsdoc) #57

Closed
12 tasks done
art-in opened this issue Nov 21, 2017 · 1 comment
Closed
12 tasks done

static type checking (js + jsdoc) #57

art-in opened this issue Nov 21, 2017 · 1 comment

Comments

@art-in
Copy link
Owner

art-in commented Nov 21, 2017

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 check types of dispatched actions #65)
  • (params) PropTypes (with @typedef Props) (forked to check types of own-props in 'connect' #66)
  • guard-object-props
  • webpack --watch mode (gulp build: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 art-in added the reseach label Nov 21, 2017
@art-in art-in self-assigned this Nov 21, 2017
art-in pushed a commit that referenced this issue Nov 29, 2017
@art-in art-in changed the title introduce type checking static type checking Nov 29, 2017
@art-in art-in changed the title static type checking static type checking (js + jsdoc) Nov 30, 2017
art-in pushed a commit that referenced this issue Dec 1, 2017
add type checking as another static test (along with linting)

remove webpack plugin for watched type checking, since console errors do not help much when code editor can show errors right in the code (vscode)
art-in pushed a commit that referenced this issue Dec 1, 2017
art-in pushed a commit that referenced this issue Dec 1, 2017
art-in pushed a commit that referenced this issue Dec 3, 2017
@art-in
Copy link
Owner Author

art-in commented Dec 3, 2017

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 in connect.d.ts)
  • jsdoc support in typescript is bad (pain)
  • complex types would be hard or impossible to define in jsdoc (need .d.ts anyway)
  • due to lack of jsdoc support, writing typescript 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

@art-in art-in closed this as completed Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant