This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useReducer } from 'react' | |
export function updateName(name: string) { | |
return <const>{ | |
type: 'UPDATE_NAME', | |
name | |
} | |
} | |
export function addPoints(points: number) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TypeScript Fundamentals For JavaScript Developers | |
/* | |
Tutorial for JavaScript Developers wanting to get started with TypeScript. | |
Thorough walkthrough of all the basic features. | |
We will go through the basic features to gain a better understanding of the fundamentals. | |
You can uncomment the features one by one and work through this tutorial. | |
If you have any questions or feedback please connect via Twitter: | |
A. Sharif : https://twitter.com/sharifsbeat | |
*/ |
None of the string methods modify this
– they always return fresh strings.
-
charAt(pos: number): string
ES1Returns the character at index
pos
, as a string (JavaScript does not have a datatype for characters).str[i]
is equivalent tostr.charAt(i)
and more concise (caveat: may not work on old engines).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MIT License | |
// | |
// Copyright (c) 2018 Ali Sharif | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MIT License | |
// | |
// Copyright (c) 2018 Ali Sharif | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is |
- Overview of a workflow based on
env
: http://2ality.com/2017/07/npm-packages-via-babel.html env
has the optionuseBuiltins
that helps with polyfilling the standard library: https://github.com/babel/babel-preset-env#usebuiltins
Approach for untranspiled code (meant to be transpiled by Babel and, e.g., webpack):
- No package ever polyfills.
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
NewerOlder