|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "blockId": "a3336d40-3eee-4098-84f0-137681882183", |
| 5 | + "data": { |
| 6 | + "contents": "\nfunction typedKeysOf<O extends Object>(o: O) {\n return Object.keys(o) as Array<keyof O>\n}\n", |
| 7 | + "file": "src/screen.ts", |
| 8 | + "range": { |
| 9 | + "end": { |
| 10 | + "character": 2147483647, |
| 11 | + "line": 65 |
| 12 | + }, |
| 13 | + "start": { |
| 14 | + "character": 0, |
| 15 | + "line": 61 |
| 16 | + } |
| 17 | + }, |
| 18 | + "scm": { |
| 19 | + "authors": [ |
| 20 | + { |
| 21 | + |
| 22 | + } |
| 23 | + ], |
| 24 | + "branch": "pr/ts/src/screen", |
| 25 | + "file": "src/screen.ts", |
| 26 | + "remotes": [ |
| 27 | + { |
| 28 | + "name": "origin", |
| 29 | + "url": "github.com/riotrah/dom-testing-library" |
| 30 | + }, |
| 31 | + { |
| 32 | + "name": "upstream", |
| 33 | + "url": "github.com/testing-library/dom-testing-library" |
| 34 | + } |
| 35 | + ], |
| 36 | + "repoName": "dom-testing-library", |
| 37 | + "revision": "4105877a4e288d899ec83f578e803963b7e5ca21", |
| 38 | + "sameRepo": true |
| 39 | + } |
| 40 | + }, |
| 41 | + "id": "a3336d40-3eee-4098-84f0-137681882183", |
| 42 | + "type": "code", |
| 43 | + "version": 1 |
| 44 | + }, |
| 45 | + { |
| 46 | + "blockId": "d861ed7f-19da-459f-9da8-2bb8564bbff3", |
| 47 | + "data": { |
| 48 | + "formatCode": false, |
| 49 | + "isPreviewing": true, |
| 50 | + "text": "<div>TL;DR: this function can be removed and its type cast inlined into its singular call site.</div><div><br></div><div>---</div><div><br></div>This utility function is only added for its usage above for the correct types to be returned from an Object.keys call. <div><br></div><div>I use this function in my personal TS projects consistently, and usually keep it relegated to a \"utils\" file. In this case I found none, and only saw its use relevant in the one file I'm modifying.</div>" |
| 51 | + }, |
| 52 | + "id": "d861ed7f-19da-459f-9da8-2bb8564bbff3", |
| 53 | + "type": "markdown" |
| 54 | + }, |
| 55 | + { |
| 56 | + "blockId": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee", |
| 57 | + "data": { |
| 58 | + "contents": " : typedKeysOf(queries).reduce<typeof initialValue>((helpers, key) => {\n helpers[key] = () => {\n", |
| 59 | + "file": "src/screen.ts", |
| 60 | + "range": { |
| 61 | + "end": { |
| 62 | + "character": 2147483647, |
| 63 | + "line": 54 |
| 64 | + }, |
| 65 | + "start": { |
| 66 | + "character": 0, |
| 67 | + "line": 53 |
| 68 | + } |
| 69 | + }, |
| 70 | + "scm": { |
| 71 | + "authors": [ |
| 72 | + { |
| 73 | + |
| 74 | + }, |
| 75 | + { |
| 76 | + |
| 77 | + } |
| 78 | + ], |
| 79 | + "branch": "pr/ts/src/screen", |
| 80 | + "file": "src/screen.ts", |
| 81 | + "remotes": [ |
| 82 | + { |
| 83 | + "name": "origin", |
| 84 | + "url": "github.com/riotrah/dom-testing-library" |
| 85 | + }, |
| 86 | + { |
| 87 | + "name": "upstream", |
| 88 | + "url": "github.com/testing-library/dom-testing-library" |
| 89 | + } |
| 90 | + ], |
| 91 | + "repoName": "dom-testing-library", |
| 92 | + "revision": "4105877a4e288d899ec83f578e803963b7e5ca21", |
| 93 | + "sameRepo": true |
| 94 | + } |
| 95 | + }, |
| 96 | + "id": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee", |
| 97 | + "type": "code", |
| 98 | + "version": 1 |
| 99 | + }, |
| 100 | + { |
| 101 | + "blockId": "b8ef9fda-f5a7-44d6-b94f-89881b3babcc", |
| 102 | + "data": { |
| 103 | + "formatCode": false, |
| 104 | + "isPreviewing": true, |
| 105 | + "text": "This explicit generic argument is only needed due to the strictness of the above type of `initialValue`. If it were a Record<string. Function> or similar, this would not be necessary." |
| 106 | + }, |
| 107 | + "id": "b8ef9fda-f5a7-44d6-b94f-89881b3babcc", |
| 108 | + "type": "markdown" |
| 109 | + }, |
| 110 | + { |
| 111 | + "blockId": "b658661f-64c2-4ffa-8267-28a856ecb583", |
| 112 | + "data": { |
| 113 | + "contents": "const initialValue: {\n [key in keyof typeof queries | 'debug' | 'logTestingPlaygroundURL']?: Function\n} = {debug, logTestingPlaygroundURL}\n", |
| 114 | + "file": "src/screen.ts", |
| 115 | + "range": { |
| 116 | + "end": { |
| 117 | + "character": 2147483647, |
| 118 | + "line": 48 |
| 119 | + }, |
| 120 | + "start": { |
| 121 | + "character": 0, |
| 122 | + "line": 46 |
| 123 | + } |
| 124 | + }, |
| 125 | + "scm": { |
| 126 | + "authors": [ |
| 127 | + { |
| 128 | + |
| 129 | + } |
| 130 | + ], |
| 131 | + "branch": "pr/ts/src/screen", |
| 132 | + "file": "src/screen.ts", |
| 133 | + "remotes": [ |
| 134 | + { |
| 135 | + "name": "origin", |
| 136 | + "url": "github.com/riotrah/dom-testing-library" |
| 137 | + }, |
| 138 | + { |
| 139 | + "name": "upstream", |
| 140 | + "url": "github.com/testing-library/dom-testing-library" |
| 141 | + } |
| 142 | + ], |
| 143 | + "repoName": "dom-testing-library", |
| 144 | + "revision": "4105877a4e288d899ec83f578e803963b7e5ca21", |
| 145 | + "sameRepo": true |
| 146 | + } |
| 147 | + }, |
| 148 | + "id": "b658661f-64c2-4ffa-8267-28a856ecb583", |
| 149 | + "type": "code", |
| 150 | + "version": 1 |
| 151 | + }, |
| 152 | + { |
| 153 | + "blockId": "8fd99820-c502-4cf7-a0a8-a36783d0226b", |
| 154 | + "data": { |
| 155 | + "formatCode": false, |
| 156 | + "isPreviewing": true, |
| 157 | + "text": "This index signature is a little narrow/strict/literal, so it might not really make much sense wrt how it's used, though it is _correct_." |
| 158 | + }, |
| 159 | + "id": "8fd99820-c502-4cf7-a0a8-a36783d0226b", |
| 160 | + "type": "markdown" |
| 161 | + } |
| 162 | + ], |
| 163 | + "graphViewMetadata": { |
| 164 | + "edges": [ |
| 165 | + { |
| 166 | + "id": "b658661f-64c2-4ffa-8267-28a856ecb583_right_8fd99820-c502-4cf7-a0a8-a36783d0226b_left_cNRjCwpxSgK9FfFKyfIbAw", |
| 167 | + "source": "b658661f-64c2-4ffa-8267-28a856ecb583", |
| 168 | + "sourceHandle": "right", |
| 169 | + "target": "8fd99820-c502-4cf7-a0a8-a36783d0226b", |
| 170 | + "targetHandle": "left" |
| 171 | + }, |
| 172 | + { |
| 173 | + "id": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee_right_b8ef9fda-f5a7-44d6-b94f-89881b3babcc_left_g89-1A6dQxeVITZ5CASgBQ", |
| 174 | + "source": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee", |
| 175 | + "sourceHandle": "right", |
| 176 | + "target": "b8ef9fda-f5a7-44d6-b94f-89881b3babcc", |
| 177 | + "targetHandle": "left" |
| 178 | + }, |
| 179 | + { |
| 180 | + "id": "a3336d40-3eee-4098-84f0-137681882183_right_d861ed7f-19da-459f-9da8-2bb8564bbff3_left_Jdu4QEkKQ46HN7MSydzI7A", |
| 181 | + "source": "a3336d40-3eee-4098-84f0-137681882183", |
| 182 | + "sourceHandle": "right", |
| 183 | + "target": "d861ed7f-19da-459f-9da8-2bb8564bbff3", |
| 184 | + "targetHandle": "left" |
| 185 | + }, |
| 186 | + { |
| 187 | + "id": "b658661f-64c2-4ffa-8267-28a856ecb583_bottom_9c8325c1-40c6-440e-89f7-f6fbdf77e3ee_top_hzTQqOEOQ2SIRM8hgvJ1ww", |
| 188 | + "source": "b658661f-64c2-4ffa-8267-28a856ecb583", |
| 189 | + "sourceHandle": "bottom", |
| 190 | + "target": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee", |
| 191 | + "targetHandle": "top" |
| 192 | + }, |
| 193 | + { |
| 194 | + "id": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee_bottom_a3336d40-3eee-4098-84f0-137681882183_top_eYT4HBCGRZ2LBwttCzsNTg", |
| 195 | + "source": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee", |
| 196 | + "sourceHandle": "bottom", |
| 197 | + "target": "a3336d40-3eee-4098-84f0-137681882183", |
| 198 | + "targetHandle": "top" |
| 199 | + } |
| 200 | + ], |
| 201 | + "graph": { |
| 202 | + "position": [193.36349006943897, -8.24359326527275], |
| 203 | + "zoom": 0.7895860571598613 |
| 204 | + }, |
| 205 | + "nodes": [ |
| 206 | + { |
| 207 | + "blockId": "8fd99820-c502-4cf7-a0a8-a36783d0226b", |
| 208 | + "dimensions": { |
| 209 | + "height": 130, |
| 210 | + "width": 437 |
| 211 | + }, |
| 212 | + "id": "dndnode_0", |
| 213 | + "position": { |
| 214 | + "x": 375, |
| 215 | + "y": 74.99999999999999 |
| 216 | + } |
| 217 | + }, |
| 218 | + { |
| 219 | + "blockId": "d861ed7f-19da-459f-9da8-2bb8564bbff3", |
| 220 | + "dimensions": { |
| 221 | + "height": 280, |
| 222 | + "width": 436 |
| 223 | + }, |
| 224 | + "id": "dndnode_1", |
| 225 | + "position": { |
| 226 | + "x": 375, |
| 227 | + "y": 495 |
| 228 | + } |
| 229 | + }, |
| 230 | + { |
| 231 | + "blockId": "b8ef9fda-f5a7-44d6-b94f-89881b3babcc", |
| 232 | + "dimensions": {}, |
| 233 | + "id": "dndnode_2", |
| 234 | + "position": { |
| 235 | + "x": 375, |
| 236 | + "y": 315 |
| 237 | + } |
| 238 | + }, |
| 239 | + { |
| 240 | + "blockId": "b658661f-64c2-4ffa-8267-28a856ecb583", |
| 241 | + "dimensions": {}, |
| 242 | + "id": "dndnode_3", |
| 243 | + "position": { |
| 244 | + "x": -135, |
| 245 | + "y": 60 |
| 246 | + } |
| 247 | + }, |
| 248 | + { |
| 249 | + "blockId": "9c8325c1-40c6-440e-89f7-f6fbdf77e3ee", |
| 250 | + "dimensions": {}, |
| 251 | + "id": "dndnode_4", |
| 252 | + "position": { |
| 253 | + "x": -135, |
| 254 | + "y": 300 |
| 255 | + } |
| 256 | + }, |
| 257 | + { |
| 258 | + "blockId": "a3336d40-3eee-4098-84f0-137681882183", |
| 259 | + "dimensions": {}, |
| 260 | + "id": "dndnode_5", |
| 261 | + "position": { |
| 262 | + "x": -135, |
| 263 | + "y": 540 |
| 264 | + } |
| 265 | + } |
| 266 | + ] |
| 267 | + }, |
| 268 | + "text": "This is not a big deal, but is worth including the question for completeness.\n\nMore importantly, if I am to continue contributions to this project, maintainer's reactions to the referred-to code provides me insight as to the conventions and attitudes expected by maintainers.\n\n\n", |
| 269 | + "title": "TODO: Evaluate overtly narrow type", |
| 270 | + "version": 1 |
| 271 | +} |
0 commit comments