just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo.
| // The two main components are the interfaces | |
| // Generic<T, Context> and GenericArg<"identifier"> | |
| // Generic basically structurally replaces types in T that are GenericArg<S> | |
| // for some `S extends keyof Context` with `Context[S]` | |
| // See the test cases for specific uses. | |
| // ====== TESTING | |
| // Pass through for trivial types | |
| type Test00 = Generic<number>; |
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo.
| import { FieldProps } from 'formik' | |
| import React from 'react' | |
| import Select, { Option, ReactSelectProps } from 'react-select' | |
| export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({ | |
| options, | |
| field, | |
| form, | |
| }) => ( | |
| <Select |
You can use the tuple() function in tuple.ts to infer tuple types in TypeScript and cut down on the need to repeat yourself. Without tuple(), declaring a constant of a tuple type looks like this:
const daysOfTheWeek: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] =
["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];You can't do this:
const daysOfTheWeek = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]; You can use the tuple() function in tuple.ts to infer tuple types in TypeScript and cut down on the need to repeat yourself. Without tuple(), declaring a constant of a tuple type looks like this:
const daysOfTheWeek: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] =
["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];You can't do this:
const daysOfTheWeek = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]; | image: node:7.9.0 # change to match your node version | |
| cache: | |
| paths: | |
| - node_modules/ | |
| before_script: | |
| - npm install | |
| test: |
| /** | |
| * This object represents a single listener of a Singal. | |
| * A listener is simply an object with a reference to a function and thisArg, | |
| * with a priority for insertion sorting and a once flag. | |
| * @class | |
| */ | |
| class Listener { | |
| /** | |
| * @param {Function} fn - The listener function | |
| * @param {Function} [thisArg] - The listener thisArg |
Based on the example file from the announcement blog post http://sketchplugins.com/d/87-new-file-format-in-sketch-43
type UUID = string // with UUID v4 format
type SketchPositionString = string // '{0.5, 0.67135115527602085}'
type SketchNestedPositionString = string // '{{0, 0}, {75.5, 15}}'| // | |
| // WRONG | |
| /// | |
| class InMemorySparseMap<K, V> implements SparseMap<K, V> { | |
| private latest: Map<K, Updatable<V>>; | |
| private factory: ((key: K) => Observable<V>) | undefined; | |
| subscribe(key: K): Updatable<V> { | |
| let ret = this.latest.get(key); |