Skip to content

Instantly share code, notes, and snippets.

View rbiggs's full-sized avatar

Robert Biggs rbiggs

View GitHub Profile
@rbiggs
rbiggs / .json
Created December 15, 2019 00:03
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"allowJs": true,
"checkJs": true,
"moduleResolution": "node",
"alwaysStrict": true,
"strictNullChecks": false,
"emitDeclarationOnly": true,
"declaration": true,
@rbiggs
rbiggs / .ts
Created November 24, 2019 02:37
The JSX interfaces for @composi/core
export { h } from './h'
export { render } from './render'
export { run } from './runtime'
export { union } from './union'
export { batchEffects, batch } from './effects'
export { Fragment } from './fragment'
// Export types for @composi/core:
export { VNode, Props } from './vnode'
export { Send, Message, State, GetState, Program } from './runtime'
@rbiggs
rbiggs / .json
Last active October 25, 2019 22:26
tsconfig for type checking
{
"compilerOptions": {
"target": "es6",
"jsx": "react",
"allowJs": true,
"checkJs": true,
"noEmit": true,
"moduleResolution": "node",
"jsxFactory": "h"
},
@rbiggs
rbiggs / .ts
Created October 22, 2019 01:31
TypeScript Interfaces
/** Definition for item. */
interface Item {
key: number;
value: string;
}
/** The property "items" is an array of type Item. */
interface State {
newKey: number;
inputValue: string;
@rbiggs
rbiggs / .js
Last active October 21, 2019 19:22
Example of compact JSDoc type definitions.
/** Definition for item.
@typedef {{
key: number,
value: string
}} Item
*/
/** The property `items` is an array of type Item.
@typedef {{
newKey: number,
@rbiggs
rbiggs / .js
Created October 12, 2019 04:19
Function with Parameter types -- JSDoc sample
/**
* A function that takes two arguments: a name and age.
* @param {string} name
* @param {number} age
* returns {{name: string, age: number} Person object
*/
function makePerson(name, age) {
return {name, age}
}
@rbiggs
rbiggs / .js
Created October 12, 2019 03:47
// With type linting this variable will be considered of type 'string':
const name = 'Joe'
// With type linthing this variable will be considere of type 'number':
const age = 100
{
"javascript.implicitProjectConfig.checkJs": true
}
@rbiggs
rbiggs / .js
Created October 12, 2019 03:43
Set up type listing in a file
// @ts-check
import {h, render, run} from '@composi/core'
import {idb} from '@composi/idb'
// Some code here…
@rbiggs
rbiggs / .js
Created July 16, 2019 14:30
Show how to use Closure Compile syntax for optional properties
// Define generic object.
// This can have any number of properties of type any.
/**
* @typedef {Object<string, any>} Member
* @property {string} name The members's name.
* @property {number=} age The members's age.
* @property {string=} job The member's job.
*/
/**
* @type {Member} Jack