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.

74%Semicolons
26%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.

72%Declarations
28%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.

58%Type Imports
42%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.

86%Record Utility Type
14%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.

61%Named Exports
39%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.

66%Single Quotes
34%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.

79%Destructure
21%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
React Component Patterns

React Function Declarations vs Arrow Functions

Should React components be defined with function declarations or arrow functions? Explore how top TypeScript projects structure their React components.

62%Declarations
38%Functions
React Component Patterns

JSX Boolean Shorthand vs Explicit ={true}

Should boolean JSX props use the concise shorthand form or always include the explicit ={true} value? See how top TypeScript projects handle boolean prop notation.

91%Shorthand Boolean
9%Explicit ={true}
React Component Patterns

Fragment Shorthand <> vs React.Fragment

Should React fragments use the concise JSX shorthand syntax <> or the explicit React.Fragment element? See how top TypeScript projects approach this common React styling choice.

98%Fragment Shorthand
2%React.Fragment Element

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