Skip to content

Instantly share code, notes, and snippets.

View gist:e1deb5791c0b4fe46388
/* @flow */
export function foo(test: boolean, callback: () => Array<number>): Array<number|string> {
if (test) return [1, '1'];
return callback();
}
3: export function foo(test: boolean, callback: () => Array<number>): Array<number|string> {
^^^^^^ string. This type is incompatible with
3: export function foo(test: boolean, callback: () => Array<number>): Array<number|string> {
View flow-dre-errors-2
$ flow check
src/injectCallbacks.js:0
0:
^ inconsistent use of library definitions
67: detachEvent?: (type: string, listener: EventListener) => void;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined. This type is incompatible with. See: /private/tmp/flow/flowlib_2dc60f56/dom.js:67
67: detachEvent?: (type: string, listener: EventListener) => void;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See: /private/tmp/flow/flowlib_2dc60f56/dom.js:67
View flow-dre-2
/* @flow */
declare class SVGElement extends Element {}
declare class HTMLParagraphElement extends HTMLElement {
align: string;
}
type ElementRegistrationOptions<T> = {
prototype?: {
View gist:7024adb7ec765f669e41
element.js:
------------------------------
/* @flow */
declare class HTMLParagraphElement extends HTMLElement {
align: string
}
type CustomElementCallbacks = {
createdCallback?: () => void;
View customElement errors
element.js
/* @flow */
declare class HTMLParagraphElement extends HTMLElement {
align: string
}
declare class Document extends Node {
registerElement(type: string, options?: ElementRegistrationOptions): void;
}
View ComponentWithComputedWidths.js
import { default as React, Component, Children, cloneElement } from 'react';
class ComponentWithComputedWidths extends Component {
constructor(props) {
super(props);
this.state = { computedWidthsAvailable = false; computedWidths: {} };
this.updateComputedWidths = this.updateComputedWidths.bind(this);
}
updateComputedWidths() {
View brenda.js
<!-- polyfills -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.9.34/bluebird.min.js">
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/0.9.0/fetch.min.js">
<script>
var imageCache = {};
function preload(name) {
var url = "images/" + name + ".jpg";
return fetch(url) // returns a promise...
View gist:eddf922770d6c812943d
export default React.createClass({
displayName: 'Oceans Navigation Category',
propTypes: {
list: React.PropTypes.arrayOf(
React.PropTypes.shape({
humanReadableName: React.PropTypes.string,
url: React.PropTypes.string
})
View router.jsx
// bootstrap React Router
import React from 'react';
import { default as Router, Route, DefaultRoute, HistoryLocation, RouteHandler } from 'react-router';
import { Splash } from '../components_angular/splash';
import index from './index';
let oceans;
if (!PRODUCTION) {
oceans = (
<Route handler={require('./oceans/navigation')} path='oceans'>
View gist:9fc18ac3b7837d8fe3ff
import React from 'react';
const Component = React.Component;
import angular from 'angular';
const jqLite = angular.element;
export default function(outerHTML) {
class Wrapper extends Component {
static displayName = `React wrapper around Angular fragment ${outerHTML}`;