PickByValue Keeps Fields Matching A Value Type
A mapped as-clause filters interface fields by value type, so PickByValue yields a record with only the string, Date, or array fields.
Page 2 of 6
A mapped as-clause filters interface fields by value type, so PickByValue yields a record with only the string, Date, or array fields.
HTMLMediaElement.play() returns a promise that rejects with named DOMExceptions: AbortError for interruptions and NotAllowedError for autoplay blocks.
New Proxy over a typed target hands every trap the target type, so keyof guards decide what can be indexed and reads log through one place.
Iterate global regexes with a while-exec loop typed as RegExpExecArray | null, reading named groups and tracking lastIndex across matches.
startViewTransition snapshots the old DOM, awaits the update callback, then animates between snapshots; ViewTransition exposes the phases as three promises.
StorageManager.estimate() returns usage and quota for the origin, and persisted() reads whether storage survives eviction pressure.
Intersecting string with an empty object type keeps literal autocomplete while still accepting any runtime string — a plain union cannot do both.
Give structural shapes a static Symbol.hasInstance type predicate so instanceof narrows parsed JSON to LineItem without any shared class prototype.
createTreeWalker with NodeFilter.SHOW_ELEMENT and an acceptNode callback visits only matching elements, keeping the outline walk lazy and allocation-free.
Wrap Map with a TypeMap parameter so each key keeps its own value type — plain Map<K, V> forces one V across every key.
unknown swallows any union it joins while never vanishes from unions and erases intersections — the two bottom types pull in opposite directions.
util.types checks internal slots, so date-like strings, regexp-like objects, and thenables fail their checks while the predicates still narrow types.
A WeakMap typed as WeakMap<RequestOptions, NormalizedOptions> memoizes per object identity, and only objects can ever become keys.
Give each message channel its own discriminated union and postMessage typed payloads with satisfies, so worker replies narrow per kind.
Build an XOR helper from mapped Exclude keys and never-typed optionals so two config branches stay selectable but can never both fill in.
Widen or preserve tuple literals deliberately: plain arrays widen to primitives, as const keeps each element its literal type for lookup tables.
Give a class several constructor signatures over one implementation so call sites stay typed whether they pass raw parts or a parsed record.
Call checkVisibility once, or with checkOpacity and checkVisibilityCSS options, to ask whether an element is actually rendered instead of guessing.
Save a JSON config file with fs.promises.writeFile and read it back with readFile, keeping one async round trip for the whole config lifecycle.
Detect Node, worker, or browser once with globalThis and typeof guards so isomorphic code picks the right branch without touching window or global.
Load config as a JSON module with `with { type: 'json' }` so mislabeled specifiers fail at build time instead of becoming runtime surprises.
Type rest tuples as [T, ...T[]] so first() returns T instead of T | undefined and zero-length arrays fail compilation instead of crashing later.
Remove the nullable side of unions with NonNullable so lookup helpers can throw on absence and their return types still check out.
Derive argument tuples and return types from existing functions so wrappers and handlers stay in sync when the original signature changes.
Force one shared instance with a private constructor and a static getter, so new Logger() cannot compile outside the class.
Accept readonly T[] at function boundaries so sort, reverse, and push fail to compile instead of mutating a caller's array behind its back.
Mark factory parameters readonly so reordering or deduplicating an input array fails to compile instead of corrupting a shared table.
Await requestFullscreen with options, handle its rejection paths, and follow fullscreenchange plus exitFullscreen to track element state.
Verify a lookup table against a target shape with satisfies while keeping literal narrowing, so missing or misnamed rows fail at compile time.
Constrain CSS length strings to number-plus-unit shapes with template literal types, so invalid units fail compilation before parsing.
Constrain size strings to number-plus-suffix template literal types so a mistyped unit fails compilation before any parsing code runs.
Track the visual viewport during keyboard overlap with resize and scroll listeners, and keep the focused input inside the visible surface.
Type fresh config object literals against an interface so a misspelled key fails compilation, while values from wider variables skip the extra-key check.
Pin generic type arguments to a class reference without calling the constructor, so helper aliases inherit strict item types and wrong members fail compilation.
Restrict a parameter to non-primitive values with the lowercase object type, and see why the older Object and {} annotations still accept strings.
Partial Record over keyof SignupForm types per-field validation messages, keeping the error map in sync with the form interface as fields change.
The typeof type operator turns a runtime constant's full shape into a type, so nested config fields keep literal types without hand-writing an interface.
A mapped handler object keyed by the event discriminant makes dispatch exhaustive: adding a kind without a handler breaks the object literal at compile time.
Promise.any settles with the first fulfilled attempt and only throws AggregateError when every input rejects, keeping each original cause in errors.
A Record keyed by the Role union forces every role to declare its capabilities, so adding a role without a permission list fails to compile.
response.json() and response.text() drain the same stream once; bodyUsed flips to true and a second read throws, while clone forks the body for two consumers.
Decoding a payload split inside a multibyte character needs stream: true; one-shot decodes turn the torn prefix into replacement characters instead.
Type a plugin registry with abstract new constructors, then cast to a concrete signature only at the instantiation boundary.
Collect every field failure and throw one AggregateError, letting callers inspect all validation errors in a single pass instead of one at a time.
Wrap cursor pagination in an async generator so callers consume pages with for await and stop early without managing tokens.
Declare class state with the accessor keyword, read the generated getter and setter, and convert Celsius to Fahrenheit through the accessor pair.
Constrain sizes with bigint literal types, compute block-aligned allocations, and reject unsupported values at compile time with ts-expect-error.
Keep userId and orderId apart at compile time with branded types, so a refactor cannot silently pass one where the other belongs.
Type a callable object with a call signature plus a property, build it with Object.assign, and call it through the interface.
Model a class factory with a construct signature, accept only compatible constructors, and build parsers with different separators.
Model curried functions with recursive conditional types so each partial application peels one parameter and keeps the remaining types.
Merge interfaces and namespaces with declaration merging so related types stay in one place and extensions type-check without inheritance.
Use declare class fields so they emit no runtime property, assign them later with Object.assign, and verify ownership before and after hydration.
Build DeepPick from recursive tuple paths so nested types survive, and intersect multiple paths into one precise shape.
Recursively strip optional modifiers with a DeepRequired utility so nested configuration objects must provide every key at every level.
Use a definite assignment assertion for a map initialized in init(), then guard reads and writes until the cache is ready.
Distribute Omit across each union member so per-variant fields survive, and compare it with the common-keys collapse of plain Omit.
Load a module on demand with dynamic import(), read its typed exports, and keep the import inside an async function so startup stays lazy.
Attach the underlying failure with ErrorOptions cause, then walk the cause chain to log root causes without losing the original stack.
Type an event emitter against an event map so emitting or subscribing with a wrong event name or payload is a compile error.
Force every enum member to be handled by routing the default branch through a never assignment, so adding a variant fails the build.
Use Extract with a channel discriminant to derive per-variant required shapes, then switch exhaustively over the narrowed union.
Declare overload signatures so callers get precise return types per argument shape, with one implementation handling the union.
Constrain generic parameters with keyof so a helper can only be called with real property names, and the return type follows the key.
Augment the built-in Window interface with declare global, add typed application fields, and read them through a narrowed global scope.
Read import.meta.url, resolve a sibling fixture with new URL, and inspect the resulting file URL and query parameters.
Locate module specifiers with import.meta.resolve, check node and file URL results, and resolve a relative asset path without reading the file.
Derive field types with indexed access types, write a generic getField helper, and index the whole object with keyof.
Use infer extends inside conditional types to capture tuple members as string or number literals, with a never fallback for mismatches.
Merge three interface declarations into one type, add optional fields from each block, and inspect the combined key union.
Extend a class with an interface to inherit its members, attach extra audit fields, and call inherited methods on the typed instance.
Combine call signatures with an intersection type, implement one runtime function, and call the overloaded converter with string, number, and boolean.
Derive union types from a frozen object with keyof typeof, keeping string literals and lookup tables in sync without a separate enum.
Use mapped type modifiers to add or remove readonly and optional flags, producing mutable, locked, and key-filtered variants of one model.
Map over tuple keys so each element keeps its position literal, then build indexed rows and read the preserved tuple length.
Merge a namespace with a function or class to attach constants and factory helpers, keeping one name for related runtime values.
Type argument lists with optional tuple elements, destructure defaults for missing entries, and keep optional elements at the end of the tuple.
Declare constructor parameter properties with private, public, and protected modifiers, then read the generated instance fields.
Carry a phantom type parameter through draft, paid, and shipped stages so invalid workflow transitions fail at compile time.
Derive a variant of a draft type where chosen keys become required, while another helper turns selected keys back into optional ones.
Keep literal types while still checking a shape with satisfies, so you get validation and precise inference in the same declaration.
Read a function expected this type with ThisParameterType, strip it using OmitThisParameter, and bind a handler without losing parameters.
Type object literal methods with ThisType so this refers to the combined data and methods shape, including inside factory helpers.
Answer compile-time membership questions with a recursive Includes type over literal tuples, including a negative uppercase case.
Implement compile-time addition and subtraction by building tuple types and reading their length, keeping arithmetic in the type system.
Mark type-only imports with import type so transpilers erase them and runtime bundles never pull modules used solely for annotations.
Type Object.entries helpers so iteration keeps each key correlated with its own value type instead of collapsing to a wide union.
Declare unique symbol keys so object brands cannot be forged with plain strings and only the owning module can mint valid values.
Use a using declaration with Symbol.dispose to release a stopwatch at scope exit, even when the surrounding function returns early.
Derive create, update, and response DTOs from one domain type with Pick, Omit, Partial, and Required so they never drift apart.
Declare wildcard modules for CSS, SVG, and virtual imports, derive module types with typeof import, and keep asset imports typed.
Pair two tuples position by position with a recursive Zip type, and see how the result stops when one side runs out.
Validate untrusted input with a small hand-rolled parser that returns a typed result — no schema library needed for flat shapes.
Type dynamic-key objects with index signatures and Record so dictionary-style access stays checked without hard-coding every key.
Freeze data shapes at the type level with readonly, ReadonlyArray, and as const so mutation bugs become compile errors.
Turn ad-hoc runtime checks into reusable type guards so parsed JSON flows into typed code paths without repeated assertions.
The intrinsic Capitalize type transforms literal unions inside the type system, so mapped keys like onHomeClick are derived and checked, never hand-written.
The & operator stacks independent interfaces into one stricter type, and a conflicting field between members collapses to never at compile time.
A Partial Record over literal endpoint keys tracks hit counts, so misspelled endpoints fail to compile and absent keys stay undefined instead of zero.
Abort the previous request the moment a newer one starts and drop superseded results, so a slow response can never overwrite the newest answer.