Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@OliverJAsh
OliverJAsh / Img.tsx
Created July 14, 2024 17:37
React workaround for Safari bugs
import * as React from 'react';
export const Img = React.forwardRef<HTMLImageElement, ImgProps>(
({ loading, sizes, srcSet, src, ...props }, ref) => (
<img
ref={ref}
// This must be set before `srcSet` + `src` to workaround a Safari bug:
// https://bugs.webkit.org/show_bug.cgi?id=276586#c1
loading={loading}
// This must be set before `srcSet` to workaround a Safari bug:
{
"scripts": [],
"styles": []
}
@OliverJAsh
OliverJAsh / index.html
Last active January 12, 2024 10:54
test
‎‎​
{
"scripts": [],
"styles": []
}
import * as React from 'react';
const useIsFirstRender = (): boolean => {
const isFirst = React.useRef(true);
if (isFirst.current) {
isFirst.current = false;
return true;
} else {
import * as React from 'react';
const useIsFirstRender = (): boolean => {
const isFirst = React.useRef(true);
if (isFirst.current) {
isFirst.current = false;
return true;
} else {
diff --git a/cjs/react-dom.production.min.js b/cjs/react-dom.production.min.js
index 7bbc786deca6afaee7c96ed87fcdcfbbea03f11e..28f9f729d3fb0786f77c912e7251f6a1e23e9077 100644
--- a/cjs/react-dom.production.min.js
+++ b/cjs/react-dom.production.min.js
@@ -115,7 +115,19 @@ vf(x),u--;for(;w--;){if(t===x||null!==x&&t===x.alternate)break b;t=vf(t);x=vf(x)
xa.controlled&&"number"===h.type&&cb(h,"number",h.value)}xa=d?ue(d):window;switch(a){case "focusin":if(me(xa)||"true"===xa.contentEditable)Qe=xa,Re=d,Se=null;break;case "focusout":Se=Re=Qe=null;break;case "mousedown":Te=!0;break;case "contextmenu":case "mouseup":case "dragend":Te=!1;Ue(g,c,e);break;case "selectionchange":if(Pe)break;case "keydown":case "keyup":Ue(g,c,e)}var $a;if(ae)b:{switch(a){case "compositionstart":var ba="onCompositionStart";break b;case "compositionend":ba="onCompositionEnd";
break b;case "compositionupdate":ba="onCompositionUpdate";break b}ba=void 0}else ie?ge(a,c)&&(ba="onCompositionEnd"):"keydown"===a&&229===c.keyCode&&(ba="onCompositi
import * as A from 'fp-ts/Array';
import { pipe } from 'fp-ts/function';
import * as IO from 'fp-ts/IO';
// Space: https://unicodeplus.com/U+0020
const space = String.fromCharCode(32);
// Narrow No-Break Space: https://unicodeplus.com/U+202F
const narrowNoBreakSpace = String.fromCharCode(8239);
// Thin Space: https://unicodeplus.com/U+2009
const thinSpace = String.fromCharCode(8201);
import { TSESLint, TSESTree } from '@typescript-eslint/utils';
import * as tsutils from 'tsutils';
import * as ts from 'typescript';
import { getChecker, getParserSvc, ruleCreator } from '../utils';
export const RequireObjectTypeAnnotations = ruleCreator({
defaultOptions: [],
meta: {
docs: {

Require type annotations for objects

For object literals without type annotations, many TypeScript features don't work. Contrived example:

type User = { name: string; age: number };

const makeUser = () => ({ name: 'bob', age: 123 });