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.

92%Spaces
8%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.

69%Declarations
31%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.

96%Array Bracket Notation
4%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.

51%Type Imports
49%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.

82%Record Utility Type
18%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.

95%Constructor Generics
5%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.

58%Named Exports
42%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

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