Instead of always running source .env
before running yarn
, you can add your dev secrets like NPM_TOKEN
or OPEN_AI_API_KEY
to a global dev environmental variable file on your machine (e.g. dev.env
) then add this to your .bashrc
to source it on startup:
# dev.env
export NPM_TOKEN=<create one in npm settings>
# bashrc
source ~/dev.env
nvm
is a version manager for node.js which lets you easily switch between different node versions. You can define an .nvmrc
file in your node project which enforces the node version standardization with your codebase collaborators.
Install
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
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 React, { useState } from "react"; | |
const UiState = { | |
LOADING: "LOADING", | |
ONLINE: "ONLINE", | |
OFFLINE: "OFFLINE", | |
}; | |
const UiStateMessageMap = { | |
[UiState.LOADING]: "Loading...", |
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 React, { useState } from "react"; | |
function FriendStatus(props) { | |
const [isOnline, setIsOnline] = useState(null); | |
useEffect(() => { | |
function handleStatusChange(status) { | |
setIsOnline(status.isOnline); | |
} | |
ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange); |
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
function foo() { | |
let res = '' | |
let j = 10 | |
for(let i=0; i<j; i++) { | |
// uncommenting ... the following line causes error | |
// var j = 5 | |
res += `${j}, ` | |
j -= 1 | |
} |
The example is taken from TypeScript's quick start tutorial
In JavaScript
const greeter = (person) => "hello "+person;
greeter([1,2,3]) // "hello 1,2,3"
In TypeScript
Helpful Migration Guides:
NewerOlder