Best practices for typescripts
|
✘ use String
|
✘ use Number
|
|
✘ use Object
|
✘ use Boolean
|
|
✘ put more general overloads before more specific ones
|
|
✔︎ sort overloads more general signatures after more specific signatures
|
|
✘ write several overloads that differ only in trailing parameters
|
|
✔︎ use optional parameters whenever possible
|
|
✘ write overloads that differ by type in only one argument position
|
|
✔︎ use union types whenever possible
|
|
"forceConsistentCasingInFileNames": true
|
|
"strict": true
|
|
"no-null-keyword": true
|
|
"noImplicitReturns": true
|
|
"noUnusedLocals": true
|
|
{ "no-null-keyword": true }
|
|
type Optional<T> = T | undefined
|
|
✘ use the return type any
|
|
✔︎ use the return type void
|
|
✘ use optional parameters in callbacks unless you really mean it
|
|
✔︎ write callback parameters as non-optional
|
|
✔︎ write callback parameters as non-optional
|
|
✘ write separate overloads that differ only on callback arity
|
|
✔︎ write a single overload using the maximum arity
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.