TruckJS
TruckJS
Sep 7, 2018 · 1 min read

You might like my approach: JSDoc comments for type information with TypeScript for type checking.. If you would prefer to just write JavaScript but also get great IntelliSense and type safety, Visual Studio Code has an option to dynamically check your JavaScript with its TypeScript language service. To work you need to provide basic type information with JSDoc comments. As a side benefit, you get great IntelliSense.

For sure JSDoc comments are more verbose than TypeScript or Flow. However, Microsoft uses JSDoc comments in the d.ts files they provide with TypeScript. The fact is that TypeScript uses the verbose descriptions you provide in JSDoc comments to present a richer, more informative popup on hover and during code completion.

Most JavaScript developers are familiar with JSDoc since its the defacto way of commenting JavaScript for a long time.

The plus is, no compilation step because this is just JavaScript. The comments are standard JavaScript comments. When you minify, they get removed automatically. While not as sophisticated as the type systems provided by TypeScript and Flow, JSDoc was created to describe how JavaScript works. So I feel it’s closer to what we’re doing in JavaScript than TypeScript.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade