TypeScript coding guidelines & configs for Formik
These guidelines are adapted from the TypeScript core's contributor coding guidelines.
Table of Contents
null
and undefined
any
isXXXing
or hasXXXXed
for variables representing states of things (e.g. isLoading
, hasCompletedOnboarding
).React.lazy()
, Gatsby and Next.js pages
, typography.js
)<ComponentName>Props
and <ComponentName>State
. The only exception is when writing a render prop. In this situation, you, the author, should call the interface for your component's props <ComponentName>Config
and then the render prop interface <ComponentName>Props
so it is easy for everyone else to use.null
and undefined
null
. EVER. If null is used (like in legacy Redux code), it should be kept isolated from other code with selectors.@see <url>
and the current date when referencing external resources, blog posts, tweets, snippets, gists, issues etc.any
unknown
..d.ts
file in a typings
directory. Document the date and version of the module you are typing at the top of the file.unknown
For a variety of reasons, we avoid certain constructs, and use some of our own. Among them:
for..in
loops over .reduce
if it makes the code clearer or if you think you may need to do async work since you can await
inside of it.(x) => x + x
is wrong but the following are correct:
x => x + x
(x,y) => x + y
<T>(x: T, y: T) => x === y
for (var i = 0, n = str.length; i < 10; i++) { }
if (x < 10) { }
function f(x: number, y: string): void { }
var x = 1; var y = 2;
over var x = 1, y = 2;
).MIT LICENSE