Skip to content

Instantly share code, notes, and snippets.

@dzNavitski
dzNavitski / comment.md
Created June 4, 2018 12:00 — forked from staltz/comment.md
Nested Pick<T, K> in TypeScript 2.2

TypeScript supports Pick to allow you to get a "subset" object type of a given type, but there is no built-in Pick for deeper nested fields.

If you have a function that takes a large object as argument, but you don't use all of its fields, you can use Pick, Pick2, Pick3, etc to narrow down the input type to be only just what you need. This will make it easier to test your function, because when mocking the input object, you don't need to pass all fields of the "large" object.

@dzNavitski
dzNavitski / index.html
Created February 20, 2023 11:51
RRWEB JS animation issue
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/rrweb@latest/dist/rrweb.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/rrweb@latest/dist/rrweb.min.js"></script>
<script type="module">
// @ts-ignore
const events = [];
const stopFn = rrweb.record({
@dzNavitski
dzNavitski / rrweb-animation.json
Created February 20, 2023 11:53
rrweb-animation
[{"type":4,"data":{"href":"http://127.0.0.1:8080/","width":1136,"height":856},"timestamp":1676893801472},{"type":2,"data":{"node":{"type":0,"childNodes":[{"type":2,"tagName":"html","attributes":{},"childNodes":[{"type":2,"tagName":"head","attributes":{},"childNodes":[{"type":2,"tagName":"link","attributes":{"rel":"stylesheet","href":"https://cdn.jsdelivr.net/npm/rrweb@latest/dist/rrweb.min.css"},"childNodes":[],"id":4},{"type":3,"textContent":"\n","id":5},{"type":2,"tagName":"script","attributes":{"src":"https://cdn.jsdelivr.net/npm/rrweb@latest/dist/rrweb.min.js"},"childNodes":[],"id":6},{"type":3,"textContent":"\n","id":7},{"type":2,"tagName":"script","attributes":{"type":"module"},"childNodes":[{"type":3,"textContent":"SCRIPT_PLACEHOLDER","id":9}],"id":8},{"type":3,"textContent":"\n\n","id":10}],"id":3},{"type":2,"tagName":"body","attributes":{},"childNodes":[{"type":2,"tagName":"popup-info","attributes":{"img":"img/alt.png","data-text":"Your card validation code (CVC) is an extra security feature — it is