Skip to content

Instantly share code, notes, and snippets.

View RyanCavanaugh's full-sized avatar
🏃‍♂️
Catching up

Ryan Cavanaugh RyanCavanaugh

🏃‍♂️
Catching up
View GitHub Profile

Strict Environment

Problem Statement

Strict Environment is intended to address three distinct problems that are frequently encountered by TypeScript developers.

This is an alternative approach to solving the problems that placeholder types were intended to address.

Problem 1: Augmentation Pollution

@RyanCavanaugh
RyanCavanaugh / text.txt
Created January 3, 2020 19:36
TypeScript Checklist
Programming Language Checklist
by Colin McMillen, Jason Reed, and Elly Jones.
You appear to be advocating a new:
[ ] functional [ ] imperative [ ] object-oriented [ ] procedural [ ] stack-based
[x] "multi-paradigm" [ ] lazy [ ] eager [x] statically-typed [ ] dynamically-typed
[ ] pure [ ] impure [ ] non-hygienic [ ] visual [ ] beginner-friendly
[ ] non-programmer-friendly [ ] completely incomprehensible
programming language. Your language will not work. Here is why it will not work.
You appear to believe that:
@RyanCavanaugh
RyanCavanaugh / empty.graphql
Created August 8, 2019 20:57
Failing GraphQL query
{
issue_1: repository(owner: "microsoft", name: "TypeScript") {
issueOrPullRequest(number: 1) {
...IssueOrPRBody
}
}
issue_2: repository(owner: "microsoft", name: "TypeScript") {
issueOrPullRequest(number: 2) {
...IssueOrPRBody
}
@RyanCavanaugh
RyanCavanaugh / object-keys.md
Last active May 15, 2019 22:52
Breaking Changes 3.5

Object.keys rejects primitives in ES5

Background

In ECMAScript 5 environments, Object.keys throws an exception if passed any non-object argument:

// Throws if run in an ES5 runtime
Object.keys(10);
@RyanCavanaugh
RyanCavanaugh / log.txt
Created March 27, 2018 19:22
Failed NPM install log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm@5.6.0
3 info using node@v8.10.0
4 verbose npm-session 86fc37f069b18b6a
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall express-app57@0.0.0
7 info lifecycle express-app57@0.0.0~preinstall: express-app57@0.0.0
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'publish',
1 verbose cli '--access',
1 verbose cli 'public' ]
2 info using npm@5.3.0
3 info using node@v8.2.1
4 verbose npm-session 00feed7f2f8e4e80
5 verbose publish [ '.' ]
@RyanCavanaugh
RyanCavanaugh / data.md
Last active July 24, 2019 03:36
30-day Download Counts for @types
Package 30-Day Download Count
node 5953555
jasmine 1364049
q 1342763
lodash 1130666
react 833429
express 817781
jquery 814943
chai 646129
@RyanCavanaugh
RyanCavanaugh / script.js
Created October 24, 2016 19:20
Mark as read
var ignames = ["andy-ms", "mhegazy", "vladima"];
var i = 100;
ignames.forEach(function (nm) {
$$('ul.notifications div.avatar-stack img[alt="@' + nm + '"]:first-child').forEach(function(el) {
var e = el.parentNode.parentNode.parentNode;
var b = e.getElementsByClassName("delete")[0].getElementsByTagName("button")[0];
window.setTimeout(function() { b.click(); } , i += 100);
});
});
@RyanCavanaugh
RyanCavanaugh / tester.ts
Created July 30, 2015 18:29
Faster DefinitelyTyped test script
/// <reference path="node_modules/typescript/bin/typescriptServices.d.ts" />
/// <reference path="node/node.d.ts" />
import fs = require('fs');
let libdts = 'node_modules/typescript/bin/lib.d.ts';
eval(fs.readFileSync('node_modules/typescript/bin/typescriptServices.js', 'utf-8'));
function runTestFolder(dir: string) {
let files = fs.readdirSync(dir);