Types and .flowconfig changes
This commit is contained in:
@@ -5,7 +5,10 @@
|
|||||||
[libs]
|
[libs]
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
|
all=warn
|
||||||
|
unsafe-getters-setters=off
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
|
include_warnings=true
|
||||||
|
|
||||||
[strict]
|
[strict]
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import {
|
||||||
|
milesToKm,
|
||||||
|
ouncesToGrams,
|
||||||
|
poundsToKg as p_to_kg
|
||||||
|
} from "./module_conversions.js";
|
||||||
|
|
||||||
|
console.log(`A miss is as good as ${milesToKm(1)} kilometers.`);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`${ouncesToGrams(1)} grams of protection `,
|
||||||
|
`are worth ${p_to_kg(1) * 1000} grams of cure.`
|
||||||
|
);
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
|
type conversion = number => number;
|
||||||
|
|
||||||
|
const SPEED_OF_LIGHT_IN_VACUUM_IN_MPS = 186282;
|
||||||
|
const KILOMETERS_PER_MILE = 1.60934;
|
||||||
|
const GRAMS_PER_POUND = 453.592;
|
||||||
|
const GRAMS_PER_OUNCE = 28.3495;
|
||||||
|
|
||||||
|
const milesToKm: conversion = m => m / KILOMETERS_PER_MILE;
|
||||||
|
const kmToMiles: conversion = k => k * KILOMETERS_PER_MILE;
|
||||||
|
|
||||||
|
const poundsToKg: conversion = p => p / (GRAMS_PER_POUND / 1000);
|
||||||
|
const kgToPounds: conversion = k => k * GRAMS_PER_POUND / 1000;
|
||||||
|
|
||||||
|
const gramsToOunces: conversion = g => g / GRAMS_PER_OUNCE;
|
||||||
|
const ouncesToGrams: conversion = o => o * GRAMS_PER_OUNCE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
It's usually preferred to include all "export"
|
||||||
|
statements together, at the end of the file.
|
||||||
|
You need not have a SINGLE export, however.
|
||||||
|
*/
|
||||||
|
export { milesToKm, kmToMiles };
|
||||||
|
export { poundsToKg, kgToPounds, gramsToOunces, ouncesToGrams };
|
||||||
|
export { SPEED_OF_LIGHT_IN_VACUUM_IN_MPS };
|
||||||
@@ -20,7 +20,7 @@ class Person {
|
|||||||
first: string;
|
first: string;
|
||||||
last: string;
|
last: string;
|
||||||
|
|
||||||
constructor(first, last) {
|
constructor(first: string, last: string) {
|
||||||
this.first = first;
|
this.first = first;
|
||||||
this.last = last;
|
this.last = last;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user