This file contains hidden or 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
// @ts-check | |
/** | |
* @typedef {{ items: Array<CartItem> }} Cart | |
* @typedef {{ | |
* sku: string, | |
* name: string, | |
* price: number, | |
* color?: Color, | |
* size?: Size, |
This file contains hidden or 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
abap: ABAP | |
bat: Windows Bat | |
bib: BibTex | |
c: C | |
clj: Clojure | |
coffee: CoffeeScript | |
cpp: C++ | |
cs: C# | |
cshtml: Razor page/view | |
css: CSS |
This file contains hidden or 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
abap: ABAP | |
bat: Windows Bat | |
bibtex: BibTeX | |
clojure: Clojure | |
coffeescript: Coffeescript | |
c: C | |
cpp: C++ | |
csharp: C# | |
css: CSS | |
diff: Diff |
This file contains hidden or 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 from 'react' | |
export interface LabeledProps { | |
label: string | |
/** | |
* @default 'input' | |
*/ | |
children?: React.ReactNode | |
/** | |
* @default 'label' |
This file contains hidden or 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
type ObjectPairs<T, X = keyof T, Y = string> = Array<[X, Y]> | Map<X, Y> | |
export function objectFromEntries< | |
T extends { [key: string]: any } = { [key: string]: any }, | |
P extends ObjectPairs<T> = ObjectPairs<T> | |
>(pairs: P) { | |
const result = {} as T | |
for (const [key, value] of pairs.entries()) { | |
result[key] = value | |
} | |
return result |
This file contains hidden or 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 { FC, useCallback } from 'react' | |
import { connect } from 'react-redux'; | |
import addToCart from '../actions/cart' | |
import useAddToCart, { UseAddToCartOptions } from './useAddToCart' | |
interface DispatchProps { | |
onSubmit(options: UseAddToCartOptions): Promise<void>, | |
} |
This file contains hidden or 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 { createNinja, Katana, Shuriken } from './entities'; | |
export default { | |
Warrior: createNinja, | |
Weapon: () => new Katana(), | |
ThrowableWeapon: () => new Shuriken(), | |
}; |
This file contains hidden or 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 { Action } from 'redux'; | |
import { AppActionCreator } from '.'; | |
interface FooAction extends Action<'FOO'> { | |
payload: string; | |
} | |
export const foo: AppActionCreator<FooAction> = ( | |
bar: string, |
This file contains hidden or 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
export default interface ResponsePayload { | |
errors?: ResponsePayloadError[]; | |
// tslint:disable-next-line:no-any | |
[key: string]: any; | |
} | |
/** | |
* https://jsonapi.org/format/#error-objects | |
*/ | |
export interface ResponsePayloadError { |
This file contains hidden or 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 transpile, { Writer } from './transpile'; | |
describe('transpile', () => { | |
describe('given a reader that always reads "foobarbaz"', () => { | |
const reader = { read: () => 'foobarbaz' }; | |
describe('given a default writer', () => { |