marius-townhouse
- 83 skills
- 0 followers
- 6 hours ago last updated
- ▌ Use Readonly · marius-townhouseUse when passing arrays or objects to functions. Use when mutation bugs occur. Use when wanting to signal that data should not be modified.
- ▌ Branded Types · marius-townhouseUse when primitive types need semantic distinction. Use when string or number types have different meanings. Use when you need nominal typing.
- ▌ Dom Hierarchy · marius-townhouseUse when working with DOM APIs. Use when typing element references. Use when creating DOM utilities. Use when handling events. Use when manipulating the DOM.
- ▌ Tagged Unions · marius-townhouseUse when modeling states or variants. Use when interface has union properties. Use when different states have different data requirements.
- ▌ Type Coverage · marius-townhouseUse when measuring type safety. Use when any types creep in. Use when migrating from JavaScript.
- ▌ Types As Sets · marius-townhouseUse when reasoning about type relationships. Use when confused by union or intersection types. Use when extends feels counterintuitive.
- ▌ Allowjs Mixing · marius-townhouseUse when migrating JavaScript to TypeScript. Use when gradually adopting TypeScript. Use when working with mixed codebases. Use when converting large projects. Use when teams are learning TypeScript.
- ▌ Evolving Types · marius-townhouseUse when types change as code executes. Use when arrays are built incrementally. Use when working with any[] that narrows.
- ▌ Limit Any Type · marius-townhouseUse when tempted to use any type. Use when getting type errors that seem hard to fix. Use when migrating JavaScript to TypeScript.
- ▌ Tsdoc Comments · marius-townhouseUse when documenting public APIs. Use when writing library code. Use when using JSDoc-style comments. Use when generating documentation. Use when explaining complex types.
- ▌ Type Narrowing · marius-townhouseUse when working with union types. Use when handling nullable values. Use when TypeScript says a value might be undefined. Use when working with discriminated unions.
- ▌ No Type In Docs · marius-townhouseUse when writing comments about types. Use when documenting function parameters. Use when naming variables.
- ▌ Soundness Traps · marius-townhouseUse when types don't match runtime values. Use when TypeScript misses errors. Use when understanding type system limits.
- ▌ Test Your Types · marius-townhouseUse when writing type declarations. Use when authoring libraries. Use when refactoring type utilities. Use when types and implementation are separate. Use when types contain complex logic.
- ▌ Narrow Any Scope · marius-townhouseUse when any is unavoidable. Use when working with untyped libraries. Use when silencing specific type errors.
- ▌ Tsconfig Options · marius-townhouseUse when setting up a TypeScript project. Use when confused by type checking behavior. Use when strict mode causes unexpected errors.
- ▌ Type Value Space · marius-townhouseUse when symbols are ambiguous. Use when class or typeof behaves unexpectedly. Use when destructuring fails.
- ▌ Record Types Sync · marius-townhouseUse when properties need synchronized configuration. Use when adding new properties requires updates elsewhere. Use when implementing optimization checks. Use when building property validators. Use when maintaining parallel data structures.
- ▌ Structural Typing · marius-townhouseUse when surprised by TypeScript accepting unexpected values. Use when designing function parameters. Use when testing with mock objects.
- ▌ Type Vs Interface · marius-townhouseUse when defining object types. Use when choosing between type and interface. Use when extending types.
- ▌ Valid State Types · marius-townhouseUse when designing types that represent state. Use when types allow invalid combinations. Use when state has implicit dependencies between fields.
- ▌ Callback This Type · marius-townhouseUse when callbacks use this. Use when API provides this context. Use when typing event handlers. Use when library sets this in callbacks. Use when documenting callback context.
- ▌ Consistent Aliases · marius-townhouseUse when narrowing doesn't work as expected. Use when using variables for object properties. Use when refinements are lost.
- ▌ Currying Inference · marius-townhouseUse when generic types aren't inferred. Use when builder patterns need better types. Use when creating new inference sites.
- ▌ No Null In Aliases · marius-townhouseUse when defining type aliases. Use when null/undefined appears in type definitions. Use when types are confusing.
- ▌ TS JS Relationship · marius-townhouseUse when confused about TypeScript vs JavaScript. Use when migrating JS to TS. Use when explaining TypeScript to newcomers.
- ▌ Avoid Numeric Index · marius-townhouseUse when defining array-like types. Use when tempted to use number as index type. Use when understanding array keys.
- ▌ Avoid Wrapper Types · marius-townhouseUse when typing primitives. Use when tempted to use String, Number, Boolean. Use when wrapper types appear in errors.
- ▌ Export Public Types · marius-townhouseUse when publishing libraries. Use when types appear in public APIs. Use when users need to reference types. Use when building reusable components. Use when designing library interfaces.
- ▌ Module Augmentation · marius-townhouseUse when extending third-party types. Use when adding properties to existing interfaces. Use when plugins extend core types. Use when declaration merging is needed. Use when augmenting global types.
- ▌ Async Over Callbacks · marius-townhouseUse when writing asynchronous code. Use when tempted to use callbacks. Use when composing multiple async operations.
- ▌ Code Gen Independent · marius-townhouseUse when confused about types at runtime. Use when trying to use instanceof with interfaces. Use when type errors don't prevent JavaScript output.
- ▌ Compiler Performance · marius-townhouseUse when build times are slow. Use when optimizing TypeScript projects. Use when configuring project references. Use when dealing with large codebases. Use when improving IDE responsiveness.
- ▌ Editor Interrogation · marius-townhouseUse when debugging type inference. Use when types behave unexpectedly. Use when learning unfamiliar code.
- ▌ Precise Any Variants · marius-townhouseUse when forced to use any. Use when any is too broad. Use when function types need any.
- ▌ Precise String Types · marius-townhouseUse when working with string-typed properties. Use when string values have a limited set of options. Use when keyof could provide better type safety.
- ▌ Three Versions Types · marius-townhouseUse when publishing type declarations. Use when dealing with version conflicts. Use when libraries have types. Use when managing @types packages. Use when debugging type mismatches.
- ▌ Variadic Tuple Types · marius-townhouseUse when functions accept variable arguments. Use when typing rest parameters with specific constraints. Use when building generic function compositions. Use when preserving tuple length through transformations. Use when working with typed function pipelines.
- ▌ Avoid Anecdotal Types · marius-townhouseUse when creating types from example data. Use when types don't match all cases. Use when API responses vary.
- ▌ Avoid Repeated Params · marius-townhouseUse when functions have multiple parameters of same type. Use when parameter order is easy to confuse. Use when designing function signatures.
- ▌ Domain Language Types · marius-townhouseUse when naming types. Use when types describe structure not meaning. Use when domain experts won't understand type names.
- ▌ Generics As Functions · marius-townhouseUse when defining generic types or functions. Use when constraining type parameters. Use when writing type-level code. Use when documenting generic types.
- ▌ Source Maps Debugging · marius-townhouseUse when debugging TypeScript in browser. Use when setting up build tools. Use when stack traces show compiled code. Use when breakpoints don't work. Use when deploying to production.
- ▌ Context Type Inference · marius-townhouseUse when extracting values causes type errors. Use when callback types are wrong. Use when const assertions are needed.
- ▌ Hide Unsafe Assertions · marius-townhouseUse when type assertions are necessary. Use when function implementations need any. Use when hiding unsafe code.
- ▌ Iterate Objects Safely · marius-townhouseUse when iterating over object keys and values. Use when for...in loops produce type errors. Use when Object.entries returns any types. Use when dealing with prototype pollution concerns. Use when considering Map vs object.
- ▌ Push Null To Perimeter · marius-townhouseUse when designing data structures with nullable values. Use when null checking is scattered throughout code. Use when related values have implicit null relationships.
- ▌ Template Literal Types · marius-townhouseUse when modeling structured string patterns. Use when parsing DSLs like CSS selectors. Use when transforming string types. Use when validating string formats. Use when combining with mapped types.
- ▌ Type Display Attention · marius-townhouseUse when complex types display poorly in IDE. Use when users see ugly type expansions. Use when debugging type issues. Use when building public APIs. Use when types become deeply nested.
- ▌ Distinct Special Values · marius-townhouseUse when tempted to use -1 or "" as special values. Use when indexOf returns -1. Use when special cases need representation.
- ▌ Exclusive Or Properties · marius-townhouseUse when exactly one of several properties should be present. Use when modeling mutually exclusive options. Use when building component props with alternative configurations. Use when designing API parameters that have variants.
- ▌ Exhaustiveness Checking · marius-townhouseUse when handling tagged unions. Use when adding new cases to discriminated unions. Use when switch statements must cover all cases.
- ▌ Prefer Type Annotations · marius-townhouseUse when assigning values to variables with types. Use when tempted to use type assertions. Use when TypeScript flags type errors you want to silence.
- ▌ Prefer Unknown Over Any · marius-townhouseUse when receiving values of unknown type. Use when parsing JSON. Use when working with external data. Use instead of any.
- ▌ Tail Recursive Generics · marius-townhouseUse when getting "Type instantiation is excessively deep" errors. Use when writing recursive generic types. Use when processing large or deep type structures. Use when building type-level loops.
- ▌ Write Modern Javascript · marius-townhouseUse when writing TypeScript that compiles to JavaScript. Use when configuring tsconfig target. Use when choosing language features. Use when supporting older browsers. Use when optimizing bundle size.
- ▌ Excess Property Checking · marius-townhouseUse when assigning object literals to typed variables. Use when confused by "unknown property" errors. Use when extra properties are flagged on object literals but not variables.
- ▌ Noimplicitany Completion · marius-townhouseUse when finishing TypeScript migration. Use when enabling strict mode. Use when finalizing tsconfig. Use when ensuring type safety. Use when completing adoption.
- ▌ Type Checking Vs Testing · marius-townhouseUse when deciding between types and tests. Use when catching logic errors. Use when testing edge cases. Use when building test suites. Use when validating assumptions.
- ▌ Understand Type Widening · marius-townhouseUse when confused why TypeScript infers general types. Use when const vs let gives different types. Use when literals become string or number.
- ▌ Different Variables Types · marius-townhouseUse when tempted to reuse variables. Use when variable changes type. Use when using union types for multiple purposes.
- ▌ Function Type Expressions · marius-townhouseUse when writing multiple functions with same signature. Use when implementing callbacks. Use when matching existing function types.
- ▌ Imprecise Over Inaccurate · marius-townhouseUse when types become too complex. Use when precision causes false positives. Use when accuracy is uncertain.
- ▌ Limit Optional Properties · marius-townhouseUse when adding optional properties. Use when types have many optional fields. Use when considering required vs optional.
- ▌ TS Check Jsdoc Experiment · marius-townhouseUse when experimenting with TypeScript. Use when migrating JavaScript gradually. Use when adding types to JS files. Use when teams are learning TypeScript. Use when validating JavaScript with types.
- ▌ Type Safe Monkey Patching · marius-townhouseUse when adding properties to window, document, or DOM elements. Use when extending built-in objects at runtime. Use when working with jQuery or D3 globals. Use when migrating JavaScript that uses global variables.
- ▌ Accurate Environment Model · marius-townhouseUse when defining global types. Use when augmenting window. Use when typing environment variables. Use when working with build-time constants. Use when configuring type definitions.
- ▌ Codegen Over Complex Types · marius-townhouseUse when types become extremely complex. Use when types mirror external schemas. Use when maintaining type-to-schema mappings. Use when types require extensive type-level logic. Use when types drift from data sources.
- ▌ Control Union Distribution · marius-townhouseUse when conditional types behave unexpectedly with unions. Use when boolean or never types cause surprises. Use when needing to prevent distribution over unions. Use when recursive generic types don't distribute.
- ▌ Create Objects All At Once · marius-townhouseUse when building objects incrementally. Use when adding properties after creation. Use when TypeScript errors on dynamic object construction.
- ▌ Module By Module Migration · marius-townhouseUse when migrating large codebases. Use when converting JavaScript to TypeScript. Use when managing dependencies. Use when planning migration order. Use when teams are adopting TypeScript.
- ▌ Typescript Devdependencies · marius-townhouseUse when setting up TypeScript projects. Use when installing @types packages. Use when configuring package.json. Use when publishing libraries. Use when managing dependencies.
- ▌ Avoid Inferable Annotations · marius-townhouseUse when writing type annotations on variables. Use when TypeScript can infer the type. Use when code feels cluttered with types.
- ▌ Functional Constructs Types · marius-townhouseUse when building arrays in loops. Use when types don't flow through code. Use when considering map/filter/reduce.
- ▌ Runtime Type Reconstruction · marius-townhouseUse when validating data at runtime. Use when parsing JSON. Use when types need runtime checks. Use when using io-ts or zod. Use when building validation schemas.
- ▌ Index Signature Alternatives · marius-townhouseUse when defining object types with dynamic keys. Use when tempted to use index signatures. Use when parsing CSV or JSON data.
- ▌ Liberal Accept Strict Return · marius-townhouseUse when designing function signatures. Use when creating APIs. Use when parameters have optional fields but return types feel too broad.
- ▌ Avoid Unnecessary Type Params · marius-townhouseUse when writing generic functions or types. Use when reviewing type signatures. Use when a type parameter only appears once. Use when tempted to add generics for "flexibility".
- ▌ Conditional Types Over Overloads · marius-townhouseUse when typing functions with multiple return types. Use when function behavior depends on input type. Use when dealing with union type inputs. Use when considering function overloads.
- ▌ Ecmascript Over Typescript Features · marius-townhouseUse when choosing between TypeScript and ECMAScript features. Use when writing portable code. Use when considering enum or namespace. Use when targeting multiple JavaScript environments. Use when writing library code.
- ▌ Dry Types · marius-townhouseUse when duplicating type definitions. Use when interfaces share common fields. Use when types can be derived from other types.
- ▌ Unify Types · marius-townhouseUse when similar types have minor differences. Use when union types become complex. Use when choosing between modeling differences.
- ▌ Mirror Types · marius-townhouseUse when depending on external types. Use when avoiding tight coupling. Use when external types might change. Use when building adapters. Use when types are only used internally.