Skip to content

Instantly share code, notes, and snippets.

View unional's full-sized avatar
🏎️
just-web!!!

Homa Wong unional

🏎️
just-web!!!
View GitHub Profile
@unional
unional / .gitconfig
Created January 13, 2024 21:01
My typical git config
[alias]
lo = log --oneline
# Push upstream
pu = push -u origin HEAD
co = checkout
# Purge branches deleted in remote (e.g. in GitHub)
pb = !git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
[pull]
rebase = true
[core]
@unional
unional / sort-configs.json
Last active August 31, 2020 05:42
sort-configs definitions
[{
"name": "npm",
"patterns": [{
"pattern": "package.json",
"syntax": ["json"],
"order": [
]
}]
}]
# update local to remove all remote-tracking branches
git fetch --all -p
# remove local branches with no remote branches
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
@unional
unional / package.json
Created January 27, 2018 22:15
Make semantic-release to release breaking as minor
{
"release": {
"analyzeCommits": {
"releaseRules": [
{
"breaking": true,
"release": "minor"
}
]
}
#! /bin/bash
# Thanks to Night Train:
# https://stackoverflow.com/questions/48250235/how-to-setup-travis-to-skip-script-on-particular-nodejs-version
# https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
#
# To use this, create this file (e.g. under scripts folder: ./scripts/run-on-node-version.sh)
# and give it execution permission: chmod ugo+x scripts/run-on-node-version.sh
# Then you can use it in CI configurations, e.g. .travis.yml:
# - ./scripts/run-on-node-version.sh latest "npm install --no-save coveralls && npm run coveralls"
@unional
unional / .travis.yml
Created November 20, 2017 00:31
Better travis strategy
branches:
only:
- master
- /^greenkeeper.*$/
# vs
branches:
except:
- /^v\d+\.\d+\.\d+$/
@unional
unional / event-error.js
Last active November 17, 2017 00:18
Error thrown in event listener affects emit code
const EventEmitter = require('events')
const emitter = new Eventemitter()
function shouldNotThrow() {
try {
emitter.emit('x')
}
catch {
// unfortunately, error is thrown

How to write typings

When you write typed definitions for DefinitelyTyped, you create a pull request on DefinitelyTyped with the corresponding .d.ts file and you are done. In the .d.ts file you write either an ambient internal module or ambient external module as in the handbook.

Things are a little bit different when you write a typings.

While it is definitely not harder then writing typed definitions for DefinitelyTyped, there isn't a clear term or reference on how to write a typings.

First things first...terminology

Going through the handbook and spec to understand everything you need to write typings is a great thing to do, but it isn't fun. Also, since TypeScript is rapidly improving, some information in the handbook is out of date.

@unional
unional / typings.install.ts
Created February 4, 2016 01:33
typings.install() API proposal
export interface InstallOptions {
cwd: string;
/**
* If not specified, will benerate both "browser.d.ts" and "main.d.ts"
**/
env?: "browser" | "main" | string[];
production: boolean; // Q: Not sure if this should be part of public API
}
export interface Typings {
@unional
unional / typings.init.ts
Created February 4, 2016 01:24
typings.init() API proposal
export interface InitOptions {
cwd: string;
upgrade?: boolean;
}
export interface typings {
init(options: InitOptions): void
}