Skip to content

Instantly share code, notes, and snippets.

Homa Wong unional

Block or report user

Report or block unional

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View git-purge-local-branches.sh
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
@unional
unional / package.json
Created Jan 27, 2018
Make semantic-release to release breaking as minor
View package.json
{
"release": {
"analyzeCommits": {
"releaseRules": [
{
"breaking": true,
"release": "minor"
}
]
}
View run-on-node-version.sh
#! /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 Nov 20, 2017
Better travis strategy
View .travis.yml
branches:
only:
- master
- /^greenkeeper.*$/
# vs
branches:
except:
- /^v\d+\.\d+\.\d+$/
@unional
unional / event-error.js
Last active Nov 17, 2017
Error thrown in event listener affects emit code
View event-error.js
const EventEmitter = require('events')
const emitter = new Eventemitter()
function shouldNotThrow() {
try {
emitter.emit('x')
}
catch {
// unfortunately, error is thrown
View how-to-write-typings.md

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 Feb 4, 2016
typings.install() API proposal
View typings.install.ts
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 Feb 4, 2016
typings.init() API proposal
View typings.init.ts
export interface InitOptions {
cwd: string;
upgrade?: boolean;
}
export interface typings {
init(options: InitOptions): void
}
@unional
unional / typings.js
Created Feb 2, 2016
Temp fix for using typings/tsd in jspm module: system environment
View typings.js
// Run this after you update your typings.
const gulp = require('gulp');
const replace = require('gulp-replace');
gulp.task('es6-typings', () => {
var srcPath = 'typings/browser/**/*'; // or 'typings/main/**/*' or 'typings/**/*' if you use `tsd`
gulp.src(srcPath, { base: './' })
.pipe(replace('export =', 'export default'))
.pipe(gulp.dest('./'));
});
You can’t perform that action at this time.