You can stick types to JavaScript code, that's named "TypeScript Type Declaration", and the extension is .d.ts. When TypeScript (or also an editor with intellisense) sees a javascript file and a .d.ts file with the same name, it will import the type definitions from that file.
There's a project that aims to provide type definitions for every JavaScript library, maybe you've heard talking about DefinitelyTyped.
For example:
// example.js
function hello(name) {
console.log(`Hello ${name}!`);
}
// example.d.ts
function hello(name: string);
// main.ts
import { hello } from 'example';
hello(42); // Error! "name" must be a string
The same system has been used to provide types in React
.roflextension is STILL a PDF. Literally nothing has changed for its content. If you tell a webapp tool to treat JS as TS files, then it will do so, applying the syntax checks and so on.jsextension by default.@flowtag in the beginning of the file (within a comment)