liveBook · Manning

Type inference

Type inference is the automatic deduction of program types from expressions, values, declarations, usage, or contextual constraints without requiring every type to be specified explicitly.

How 19 Manning books explain it

F# in Action: A Revised Edition of Get Programming with F#

Type inference is the compile-time deduction of expression and value types from available program information.

How it is used
Removes routine type annotations from statically typed F# values and functions while retaining compiler checks.
How deep it goes
Works through bindings, annotations, misleading errors, and inference limits using examples; does not derive the inference algorithm.
Examples
Uses an inferred integer binding, an age-comparison error, record construction, and a function-valued printer argument.
What you can do after
Diagnose/debug with it by inspecting inferred signatures and temporarily annotating a parameter to locate a type clash.

Read how F# in Action: A Revised Edition of Get Programming with F# explains type inference →

Building User-Friendly DSLs

Type inference is the algorithmic determination of expression or value types from available constraints without requiring every type to be written explicitly.

How it is used
Derives expression types for DSL projection when local AST data alone is insufficient.
How deep it goes
Implements ancestor-based inference for numbers and defers richer Hindley-Milner-style algorithms.
Examples
Uses rental-price expressions, Number objects, attributes, and the “-” and “of” operators.
What you can do after
Build it from scratch by passing AST ancestors into typeOf and centralizing contextual type logic.

Read how Building User-Friendly DSLs explains type inference →

Essential TypeScript 5, Third Edition

Type inference is the compiler's derivation of types for program elements from their values, expressions, and usage without explicit annotations.

How it is used
Checks variables, calculations, method calls, and arrays without requiring annotations at every use.
How deep it goes
Works through inferred expression and array types, then examines empty-array and subclass pitfalls and conditional-type inference.
Examples
Uses a tax calculation, a todo-list method error, initialized and empty arrays, subclass arrays, and generic property selection.
What you can do after
Diagnose/debug with it by checking inferred types in declaration files and adding annotations where inference permits errors or excludes intended values.

Read how Essential TypeScript 5, Third Edition explains type inference →

React in Depth

Type inference is the compiler's determination of a type from available values, expressions, or contextual constraints without an explicit type annotation.

How it is used
Uses inference to avoid redundant annotations while identifying React hook and callback initializers that need explicit types.
How deep it goes
Works through inferred results, generic arguments, state, context, and callback placement; does not explain compiler internals.
Examples
Uses a Fibonacci function, an appointment response, a tag form, dark-mode context, and playlist callbacks.
What you can do after
Apply it via TypeScript type arguments and annotations when React initializers or callback placement leave intended types unclear.

Read how React in Depth explains type inference →

Kotlin in Action, 2E

Type inference is the compiler's ability to determine expression types without requiring explicit type annotations everywhere.

How it is used
Reduces type-declaration boilerplate while preserving Kotlin’s statically known expression types.
How deep it goes
Explains inference from variable initializers and generic collection arguments, including cases where missing information requires explicit types.
Examples
Uses inferred `Int`, `String`, and `Double` variables plus string lists and explicitly typed empty mutable lists.
What you can do after
Apply it via Kotlin variable declarations and collection creators to omit types the compiler can deduce.

Read how Kotlin in Action, 2E explains type inference →

Modern C, Third Edition

Type inference is the compile-time deduction of type information from an expression or declaration without explicitly writing the complete type.

How it is used
Supports type-generic programming by deriving declarations from expressions and reducing repetitive type-specific cases.
How deep it goes
Explains C23 inference through declarations and a generic SWAP macro, while only summarizing broader typeof applications.
Examples
Uses inferred declarations, explicit declarations, and a generic SWAP macro with inferred pointers and temporary storage.
What you can do after
Build generic C macros that preserve operand-dependent types and evaluate captured expressions only once.

Read how Modern C, Third Edition explains type inference →

DuckDB in Action

Type inference is the automatic determination of data types from available program or expression information.

How it is used
Uses available annotations or file values to reduce manual schema work when registering functions and loading CSV data.
How deep it goes
Explains annotation-based and CSV-based inference, then contrasts them with explicit declarations and schema maintenance.
Examples
Demonstrates remove_spaces registration, Region cleanup, and Stack Overflow Users and Posts imports using automatic CSV detection.
What you can do after
Apply it via DuckDB to register Python functions and load CSV tables, while recognizing when explicit types are safer.

Read how DuckDB in Action explains type inference →

Learn Haskell by Example

Type inference is the automatic determination of expression and variable types from their usage and surrounding context.

How it is used
Uses inferred types to develop typed cipher-program definitions while retaining explicit top-level signatures for clarity.
How deep it goes
Explains contextual inference for numeric values and collections, then demonstrates polymorphic specialization without covering type-class constraints.
Examples
Uses cipher-wheel keys, numeric prefixes, typed lists and tuples, and a transform function specialized from Int to String.
What you can do after
Evaluate/understand how Haskell deduces concrete expression and function types from annotations, collection types, and polymorphic use.

Read how Learn Haskell by Example explains type inference →

100 C++ Mistakes and How to Avoid Them

Type inference is the compiler's process of determining a program entity's type from available declarations, initializers, or contextual information.

How it is used
Uses `auto` to simplify variable declarations, particularly when iterator types are verbose.
How deep it goes
Explains initializer-based deduction with worked examples, including unsigned countdown and accidental-copy hazards.
Examples
Shows vector search, reverse iteration, and student-name copies versus references.
What you can do after
Evaluate when `auto` improves declarations and when explicit types or references prevent errors and copies.

Read how 100 C++ Mistakes and How to Avoid Them explains type inference →

Learn Go with Pocket-Sized Projects

Type inference is the compiler's deduction of a generic type argument from the types of a function's input arguments.

How it is used
Simplifies calls to reusable generic functions by letting the compiler select concrete type arguments from input values.
How deep it goes
Explains input-based deduction and its returned-type limitation, while stopping short of compiler algorithm internals.
Examples
Uses a generic prettyPrint function called with float64 and string arguments.
What you can do after
Apply it via Go generic functions by omitting type arguments when input parameters determine them.

Read how Learn Go with Pocket-Sized Projects explains type inference →

Secrets of the JavaScript Ninja, Third Edition

The compile-time determination of types from surrounding declarations, expressions, or values without requiring explicit annotations.

How it is used
Uses inferred types to reduce annotations while retaining type checks across variables, parameters, and function returns.
How deep it goes
Explains inference from assigned values and context, default parameters, and function returns, including when annotations improve checking.
Examples
Uses inferred variable and callback types, default parameters, and a capitalization function with an inferred return type.
What you can do after
Apply TypeScript inference to omit redundant annotations and add parameter or return types where needed for reliable checking.

Read how Secrets of the JavaScript Ninja, Third Edition explains type inference →

Modern Angular

Type inference is the determination of static types from expressions and their surrounding usage without explicit type annotations.

How it is used
Improves Angular dependency injection and reactive-form development by replacing implicit any and fragile token or control-name typing.
How deep it goes
Explains inferred token and form types, partial values, casts, dot notation, and template diagnostics, but not inference internals.
Examples
Uses application-wide date constants, inject(Constants), and an HRMS employee form whose misspelled email control triggers a template error.
What you can do after
Diagnose Angular injection and form-control mismatches earlier through inferred properties, typed values, and template checking.

Read how Modern Angular explains type inference →

.NET in Action, Second Edition

Type inference is the compiler's deduction of a program expression or variable's type from available context and assignments.

How it is used
Frames compiler deduction while service examples show explicitly typed ASP.NET Core handler parameters.
How deep it goes
Defines deduction from context and assignments but stops short of explaining inference rules, runtime behavior, or implementation internals.
Examples
Uses ASCII-art web endpoints whose route and query parameters are declared as `string` and `string?`.

Read how .NET in Action, Second Edition explains type inference →

Fabulous Adventures in Data Structures and Algorithms

Type inference is the deduction of expression or variable types from program context and constraints without requiring every type to be written explicitly.

How it is used
Explains omitted generic and lambda types by translating inference into a unification problem.
How deep it goes
Works through term construction and substitutions, but stops short of a full type-inference implementation.
Examples
Uses a generic Frob method, a numeric argument, a collection-producing lambda, and explicit inferred substitutions.
What you can do after
Evaluate how unification solves a small generic method-inference problem and interpret each resulting substitution.

Read how Fabulous Adventures in Data Structures and Algorithms explains type inference →

Acing the Frontend Interview

Type inference is the automatic deduction of types from declarations, expressions, and usage without requiring explicit annotations everywhere.

How it is used
Uses inference to reduce unnecessary annotations while supporting maintainable code, API contracts, and interview reasoning about type safety.
How deep it goes
Progresses from explaining inference to applying it, identifying clarity trade-offs, debugging pitfalls, and architecting type-safe APIs.
Examples
Uses a review table contrasting inference fundamentals, applied coding choices, and advanced type-safe API design.
What you can do after
Apply inference for cleaner code, choose clarifying annotations, and diagnose inference issues in type-safe API design.

Read how Acing the Frontend Interview explains type inference →

Refactoring to Rust

Type inference is the compile-time deduction of expression or variable types from program context without requiring explicit annotations.

How it is used
Uses compiler-deduced local types to reduce annotation effort while preserving static checking in Rust programs.
How deep it goes
Explains inference through initializers and map insertion, while deferring detailed annotation cases to later treatment.
Examples
Contrasts Java and Rust map declarations and demonstrates inferred artwork variables initialized with structs and strings.
What you can do after
Apply it via the Rust compiler by omitting routine local annotations while checking that surrounding values constrain the intended types.

Read how Refactoring to Rust explains type inference →

100 Go Mistakes and How to Avoid Them

Type inference is the compile-time deduction of generic type arguments from a call or use context.

How it is used
Uses call context to select generic type arguments while preserving compile-time type safety.
How deep it goes
Demonstrates inferred and explicit calls, but does not detail the compiler's inference algorithm.
Examples
Uses getKeys on map[string]int and contrasts inferred getKeys(m) with explicit getKeys[string](m).
What you can do after
Apply it via generic functions by choosing inferred calls when arguments suffice and explicit type arguments when clarity requires them.

Read how 100 Go Mistakes and How to Avoid Them explains type inference →

Fast Python: High performance techniques for large datasets

How it is used
Diagnoses memory-heavy column types discovered while loading data.
How deep it goes
Diagnoses inference problems through dtype and memory inspection, then demonstrates conversions without detailing inference internals.
Examples
Compares taxi-data memory before and after datetime conversion and shows compact integer conversion for payment types.
What you can do after
Diagnose dtype warnings and reduce DataFrame memory by converting columns to appropriate types.

Read how Fast Python: High performance techniques for large datasets explains type inference →

Systems Programming with Zig

Type inference is compiler deduction of a program expression's data type from its context and values.

How it is used
Uses a function’s declared return type to infer the types of returned values in Zig.
How deep it goes
Explains inference of base-case literals from a function return type, without detailing broader inference rules.
Examples
Uses Fibonacci base cases returning 0 and 1, inferred as i32.
What you can do after
Understand how Zig infers returned literal types from a function’s declared return type.

Read how Systems Programming with Zig explains type inference →

Also covered in

What to know first

Related concepts

Questions about type inference

What is type inference?

Type inference is the automatic deduction of program types from expressions, values, declarations, usage, or contextual constraints without requiring every type to be specified explicitly.

Which Manning books explain type inference?

F# in Action: A Revised Edition of Get Programming with F#, Building User-Friendly DSLs, Essential TypeScript 5, Third Edition, React in Depth, Kotlin in Action, 2E, Modern C, Third Edition, DuckDB in Action, Learn Haskell by Example and 11 more.

What should I know before learning type inference?

Manning books that teach type inference usually introduce generics, function, string and atomic type first.

What is the difference between type inference and type hints?

Type inference is the automatic deduction of program types from expressions, values, declarations, usage, or contextual constraints without requiring every type to be specified explicitly. Type hints are source-code annotations that indicate the intended or expected types of program elements, with enforcement depending on the language and tools.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.