Skip to content

Instantly share code, notes, and snippets.

Paul dagda1

View GitHub Profile
View mock.ts
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => history,
}));
View mock.ts
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => history,
}));
View t.ts
type TransformerFunc<T> = (src: T) => any;
export type TransformerMap<S> = {
[P in keyof S]?:
| S[P]
| TransformerFunc<S>
| TransformerFunc<S[P]>
| TransformerActions
| TransformerMap<S[P]>;
};
View infer.ts
export type ComponentPropsType<C> = C extends React.FC<infer P> ? P : never;
export type ThenType<T> = T extends Promise<infer U> ? U : never;
View ExternalLink.ts
View gist:c2b5379256fd3e44fe1bb9903fd6e3e2
export async function render({ req, res }: RendererOptions): Promise<void> {
const context: StaticRouterContext = {};
const appString = renderToString(
<StaticRouter location={req.url} context={context}>
<Routes />
</StaticRouter>,
);
const scriptTags = ['vendor', 'client']
View empty.ts
export const RouteWrapper = function RouteWrapper<
P = { children?: ReactNode },
TRoute extends RouteProps = Route
>(
Wrapper: React.ComponentType<P | {}>,
RouteType: React.ComponentType<RouteProps> = Route,
options: Partial<TRoute> = {},
wrapperProps: P | {} = {},
) {
return function RouteWrapperResuslt({
View cloudSettings
{"lastUpload":"2020-07-03T06:43:54.132Z","extensionVersion":"v3.4.3"}
View hell.java
@RunWith(Courgette.class)
@CourgetteOptions(
threads = 1,
runLevel = CourgetteRunLevel.FEATURE,
rerunFailedScenarios = true,
showTestOutput = true,
))
public class TestRunner {
}
View foo.ts
interface Foo {
value?: string;
}
const item1: Foo = { value: 'foo' }
// ERROR: Object is possibly 'undefined'.
console.log(`Message ${item1.value.substring(4)}`);
const item2 = { value: 'foo' }
You can’t perform that action at this time.