Skip to content

Instantly share code, notes, and snippets.

View molily's full-sized avatar

Mathias Schäfer molily

View GitHub Profile
@molily
molily / stacktrace
Created October 15, 2021 12:24
TypeScript stacktrace
etc, repeating
at getInitializerTypeFromAssignmentDeclaration (/usr/local/lib/node_modules/typescript/lib/tsc.js:44088:97)
at getWidenedTypeForAssignmentDeclaration (/usr/local/lib/node_modules/typescript/lib/tsc.js:43987:131)
at getTypeOfFuncClassEnumModuleWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:44509:24)
at getTypeOfFuncClassEnumModule (/usr/local/lib/node_modules/typescript/lib/tsc.js:44497:51)
at getTypeOfVariableOrParameterOrPropertyWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:44316:28)
at getTypeOfVariableOrParameterOrProperty (/usr/local/lib/node_modules/typescript/lib/tsc.js:44268:28)
at getTypeOfSymbol (/usr/local/lib/node_modules/typescript/lib/tsc.js:44608:24)
at checkIdentifier (/usr/local/lib/node_modules/typescript/lib/tsc.js:56922:24)
at checkExpressionWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:63702:28)
@molily
molily / .eslintrc.js
Last active February 27, 2018 11:15
Eslint config based on eslint-config-airbnb 14.0.0, eslint-plugin-import 2.2.0, eslint-plugin-jsx-a11y 3.0.2
module.exports = {
parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true
}
},
@molily
molily / cancelablePromise-test.js
Created May 27, 2016 15:28
Cancelable Promise
import cancelablePromise, { CancelError } from '../cancelablePromise';
const originalError = new Error('original error');
const expectCancelError = (reason, message) => {
expect(reason).toEqual(jasmine.any(CancelError));
expect(reason.name).toBe('CancelError');
expect(reason.message).toBe(message || 'Promise was cancelled');
};
@molily
molily / CustomError.js
Last active May 24, 2016 11:53
Custom error class that inherits from Error
// Manual inheritance without super call. We can’t use `class` declaration
// since the Babel compilation output will call Error.call(this, arguments),
// which always returns a new Error instance instead of the instance.
// See http://www.ecma-international.org/ecma-262/6.0/#sec-error-constructor
// Apart from this change, we’re using Babel’s approach of inheritance:
// https://github.com/babel/babel/blob/v6.9.0/packages/babel-helpers/src/helpers.js#L210-L225
/* eslint-disable func-style */
function CustomError(message) {
// NO super call here
/* global KeyboardEvent */
const supportsKeyboardEvent = (() => {
try {
new KeyboardEvent('keydown'); // eslint-disable-line no-new
} catch (e) {
return false;
}
return true;
})();
@molily
molily / tests.js
Created March 9, 2016 10:47
Fail tests on console.error calls (e.g. React warnings)
// Overwrite console.error so calls to it fail a test.
// This is mostly targeted at React warnings. For example, the test should not
// cause React missing prop warnings.
/* eslint-disable no-console */
const originalConsoleError = console.error;
console.error = (...args) => {
originalConsoleError.apply(console, args);
throw new Error(`console.error was called: ${args[0]}`);
};
/* eslint-enable no-console */
@molily
molily / promisePolyfill.js
Created February 25, 2016 14:58
promisePolyfill.js
import RSVP from 'rsvp';
export default () => {
if (!window.Promise) {
window.Promise = RSVP.Promise;
// Show uncaught Promise errors on the console
RSVP.on('error', (reason) => {
/* eslint-disable no-console */
console.error('Uncaught Promise exception', reason);
/* eslint-enable no-console */
# Returns the prototype chain of an object.
# In old browsers, falls back to the __super__ property
# set up by CoffeeScript classes.
# Returns an array.
getPrototypeChain = do ->
if Object.getPrototypeOf
(object) ->
chain = []
while object = Object.getPrototypeOf(object)
chain.push object
@molily
molily / 2016.md
Last active January 1, 2016 23:52
Top tech to learn in 2016!
  • HTML
  • CSS
  • JavaScript
  • HTTP
  • Responsive design
  • Performance
  • Mobile First
  • Progressive enhancement
  • User experience
  • Accessibility