-
First, add
asdf
to the Nix configuration with the package namedasdf-vm
. Add the following line to yourconfiguration.nix
file:environment.systemPackages = with pkgs; [ asdf-vm ];
// Core assets | |
let coreAssets = []; | |
// On install, cache core assets | |
self.addEventListener('install', function (event) { | |
// Cache core assets | |
event.waitUntil(caches.open('app').then(function (cache) { | |
for (let asset of coreAssets) { | |
cache.add(new Request(asset)); |
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'
instead ofconst foo = require('foo')
to import the package. You also need to put"type": "module"
in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)
from CommonJS instead ofrequire(…)
. - Stay on the existing version of the package until you can move to ESM.
import { createStore, actionCreator } from "./redux-middleware"; | |
function reducer(state = {}, { type, payload }) { | |
switch (type) { | |
case "init": | |
return { | |
...state, | |
count: payload.count | |
}; | |
case "inc": |
import { createStore, actionCreator } from "./tiny-redux"; | |
function reducer(state = {}, { type, payload }) { | |
switch (type) { | |
case "init": | |
return { | |
...state, | |
count: payload.count | |
}; | |
case "inc": |
It's not uncommon to have a React component that takes props where some of those props are mutually exclusive. Let's imagine a case where we have a Button
component. We want our button to allow for the following possibilities:
- The button has text.
- The button has text and an icon.
- The button has an icon, but no text.
An initial implementation might look like:
const Button = ({ text, icon }: { text?: string; icon?: string }) => {
This is a quick-and-dirty walkthrough to set up a fresh project with Storybook Docs, Create React App, and TypeScript. If you're looking for a tutorial, please see Design Systems for Developers, which goes into much more depth but does not use Typescript.
The purpose of this walkthrough is a streamlined Typescript / Docs setup that works out of the box, since there are countless permutations and variables which can influence docs features, such as source code display, docgen, and props tables.
npx create-react-app cra-ts --template typescript
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj | |
Cloning into 'my-awesome-proj'... | |
ssh: connect to host github.com port 22: Connection timed out | |
fatal: Could not read from remote repository. | |
$ # This should also timeout | |
$ ssh -T [email protected] | |
ssh: connect to host github.com port 22: Connection timed out | |
$ # but this might work |