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
| https://stackoverflow.com/questions/45372227/how-to-implement-typescript-deep-partial-mapped-type-not-breaking-array-properti/49936686#49936686 | |
| export type DeepPartial<T> = { | |
| [P in keyof T]?: T[P] extends Array<infer U> | |
| ? Array<DeepPartial<U>> | |
| : T[P] extends ReadonlyArray<infer U> | |
| ? ReadonlyArray<DeepPartial<U>> | |
| : DeepPartial<T[P]> | |
| }; | |
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 type Opaque<T, K> = K & { __TYPE__: T }; | |
| // Create a new opaque type | |
| type WaffleId = Opaque<number, "waffledId">; | |
| // This function now handles the knowledge of what a waffleId is, change will only happen there if needed | |
| function makeWaffleId( number: number ): WaffleId | |
| { | |
| // ...do stuff |
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 interface PassThroughProps | |
| { | |
| children: ReactElement | |
| } | |
| export function PassThrough( props: PassThroughProps ) | |
| { | |
| const { children, ...propsToPass } = props | |
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 exampleReducerAction = Waffled | Pancaked | NOT_HANDLED_IN_SWITCH_CASE | |
| function breakfastReducer( state: any, action: exampleReducerAction ): any | |
| { | |
| // Note, for some reason action.type doesn't work | |
| switch ( action.type ) { | |
| case "PancakedAction": | |
| return "Gimme!" |
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
Show hidden characters
| { | |
| "//1//":"This doesn't seem to be needed", | |
| "compilerOptions": { | |
| // ... your setup | |
| "typeRoots": ["./custom.d.ts"] // Aka add these types on top of the other ones | |
| } | |
| } |
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 * as React from "react" | |
| import { mount } from "enzyme" | |
| import StoreProvider from "./StoreProvider" | |
| import Mock = jest.Mock | |
| jest.mock( "./StoreProvider", () => ({ | |
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
| Timer* | |
| Idle | |
| start->Running | |
| Running | |
| stop->Idle | |
| pause->Paused | |
| tick->done? | |
| Paused | |
| start->Running | |
| stop->Idle |
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
| Traffic Light | |
| Regular | |
| power outage->Power failure | |
| Green* | |
| tick->Yellow | |
| Yellow | |
| tick->Red | |
| Red | |
| tick->Green | |
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
| Timer* | |
| Idle* | |
| start->Running | |
| Running | |
| reset->Idle | |
| tick-> SpecifiedTimeElapsed? | |
| # Transient state define system’s logic without dropping into code | |
| SpecifiedTimeElapsed? |
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
| /** | |
| * NPM dependencies to install | |
| * (npm i -D gulp gulp-sass ... ) | |
| */ | |
| const gulp = require( "gulp" ), | |
| path = require( "path" ), | |
| sass = require( "gulp-sass" ), | |
| sourcemaps = require( "gulp-sourcemaps" ), | |
| autoprefixer = require( "gulp-autoprefixer" ), | |
| browserSync = require( "browser-sync" ).create() // Local server |