JavaScript / TypeScript Styleguides

TechPref

Explore the most debated coding style preferences with real-world data from popular open source projects.

Style Comparisons

Click on a comparison to explore both sides of the debate with statistics, code examples, and expert opinions.

JavaScript / TypeScript Styleguide

Spaces vs Tabs

The eternal debate in code formatting. Explore both sides with real-world data, popular project preferences, and expert opinions.

91%Spaces
9%Tabs
JavaScript / TypeScript Styleguide

Semicolons vs No Semicolons

To semicolon or not to semicolon? Explore the JavaScript style war with real-world data from popular open source projects.

73%Semicolons
27%No Semicolons
JavaScript / TypeScript Styleguide

Function Declarations vs Arrow Functions

Two ways to define functions in JavaScript. Explore the tradeoffs between traditional function declarations and modern arrow functions.

70%Declarations
30%Functions
JavaScript / TypeScript Styleguide

2 Spaces vs 4 Spaces

The indent width debate. Does more space mean better readability, or is compact code easier to scan?

100%2 Spaces
0%4 Spaces
TypeScript Styleguide

Array Types: T[] vs Array<T>

Two syntaxes for defining array types in TypeScript. Explore the differences between the simple bracket notation and the generic Array type.

97%Array Bracket Notation
3%Generic Array<T> Syntax
TypeScript Styleguide

Interface vs Type for Object Definitions

Two ways to define object types in TypeScript. Explore the differences between interfaces and type aliases for type definitions.

79%Interface
21%Type Alias
TypeScript Styleguide

Type Imports: 'type' Keyword vs Mixed Imports

Two approaches to importing types in TypeScript. Explore whether to use the 'type' keyword for type-only imports or mix them with value imports.

55%Type Imports
45%Mixed Imports
TypeScript Styleguide

Indexed Objects: Record<K, V> vs Index Signatures

Two ways to define indexed object types in TypeScript. Explore the differences between Record<K, V> utility type and index signature syntax.

85%Record Utility Type
15%Index Signature
TypeScript Styleguide

Generic Constructors: Type vs Constructor Parameters

Two ways to specify generic parameters for constructors in TypeScript. Explore whether generics belong on the type annotation or the constructor call.

96%Constructor Generics
4%Type Annotation Generics
JavaScript / TypeScript Module Patterns

Named Exports vs Default Exports

Debate: Should modules export one thing by default or require explicit naming? Analyze real-world patterns from top TypeScript projects.

59%Named Exports
41%Default Exports
JavaScript / TypeScript Styleguide

Single Quotes vs Double Quotes

String delimiters matter. Explore the quote preferences across popular TypeScript projects with real-world data.

67%Single Quotes
33%Double Quotes
React Component Patterns

Destructure Props vs Don't Destructure Props

Should React components destructure their props or access them through the props object? Explore how top TypeScript projects handle component props.

35%Destructure
65%Props Object
React Component Patterns

Destructure in Signature vs Outside Signature

When destructuring props, should it happen right in the function signature or inside the function body? Compare how top TypeScript projects split on this React styling question.

0%Destructure in Signature
100%Destructure Outside Signature

Data sourced from analysis of top TypeScript repositories on GitHub. View all repositories