TypeScript 7 Native Go Compiler: tsc, tsgo and Migration
TypeScript 7 ports the compiler to Go, and tsc is now a native binary. We measure it against TypeScript 6 on 1,001 modules and migrate a tsconfig step by step.
TypeScript is a popular open-source programming language developed and maintained by Microsoft. It is a statically typed superset of JavaScript that adds optional static typing and other features to help developers write more robust and maintainable code.
TypeScript compiles to plain JavaScript, making it compatible with all JavaScript environments and runtimes.
TypeScript 7 ports the compiler to Go, and tsc is now a native binary. We measure it against TypeScript 6 on 1,001 modules and migrate a tsconfig step by step.
TypeScript utility types create new types from an existing one, such as an all-optional copy or a subset of keys. This reference lists all 22 built-in utility types with their results, gives one example each for Partial, Pick, Omit, Record, Exclude, ReturnType and Awaited, and shows the real tsc errors we get when we use them wrong.
The TypeScript satisfies operator checks a value against a type and keeps the narrow type TypeScript inferred for it. We compare satisfies with type annotations and as assertions, use it on settings objects, Record maps and as const tables, and read the real tsc errors for the common mistakes.
A TypeScript decorator is a function that we put above a class or class member with @name, and it can replace that member with a new version. Learn each decorator kind with runnable TypeScript 7 examples, the order decorators run in, the usual compiler errors, and how standard decorators differ from experimentalDecorators used by Angular, NestJS and TypeORM.
TypeScript 6 is the last TypeScript release with a JavaScript-based compiler. It changes tsconfig.json defaults such as strict and types, and deprecates options that TypeScript 7 removes. This overview lists every change with the real tsc errors and an upgrade checklist for 5.x projects.
TypeScript 7 is the Go port of the TypeScript compiler and checks the same language as TypeScript 6 about 10 times faster. We compare both versions in a table, time tsc 6.0.3 and tsc 7.0.2 on the same project, and show what still needs TypeScript 6 and how to switch.
Declare a typed array of objects with an interface or type alias, then add, find, filter, sort, group and update its objects without surprises.
TypeScript has no Vector class. Model each vector as a tuple such as [x: number, y: number, z: number], store them in an array, and do vector math with typed functions.
A subclass replaces a parent method by overriding it. Learn the override keyword, noImplicitOverride, super calls and the rules the compiler checks.
An interface cannot be instantiated with new, but any object with the right shape matches it. Learn seven ways to create such objects and when to use each.
instanceof checks whether an object was created by a class and narrows its type. Learn how it works, where it fails, and how to check interfaces with in and type guards.
An interface describes a shape and disappears after compilation; a class describes a shape, holds code and exists at runtime. Compare them feature by feature.
TypeScript generics let one function, class or interface work with many types while the compiler checks every value. Examples cover constraints, keyof, defaults and const type parameters.
Extend a TypeScript interface with extends, combine several parents, merge declarations, and learn when an intersection type (&) is the better fit.
A TypeScript interface names the shape of an object. Learn to declare one, use optional and readonly properties, implement it in a class, and choose between an interface and a type alias.
TypeScript exception handling uses try, catch, finally and throw, with an unknown catch variable under strict. Examples cover custom Error classes, cause, instanceof and async errors.
The map() method returns one result per element, while flatMap() can return zero, one or many and flattens them one level. Tested examples on TypeScript 7.0.2.
A Record types a plain object; a Map is a runtime collection. Compare them on keys, order, JSON, type checks and user input, and convert one into the other.
Record
TypeScript checks types at compile time and outputs plain JavaScript; JavaScript checks them only at runtime. A side-by-side comparison with real compiler errors.
Optional parameters may be left out and are undefined inside the function; default parameters fill in a value instead. Examples cover undefined vs null, order rules and options objects.
How slice(start, end) copies part of a TypeScript array: excluded end index, negative indexes, pagination and chunks, shallow copies, slice() vs splice(), and result types.
Remove items from a TypeScript array by position or by value, in place or on a copy, with the common bugs (-1 index, splice in a loop, delete) shown and fixed.
Add items to the end, start or any index of a TypeScript array, or to a new array with spread, concat() and toSpliced(), with the compiler errors explained.
Get the current date in TypeScript, create dates, add days and months, compare and format them, and avoid the time zone and JSON pitfalls of the Date object.
Find elements in a TypeScript array with find(), findIndex(), findLast() and findLastIndex(), handle the T | undefined result, and pick the right search method.
All TypeScript tutorials on howtodoinjava.com, grouped by topic: basics, types, operators, arrays, collections, functions, interfaces and classes.
Number.isFinite() is the reliable way to check if a variable is a number in JavaScript. Learn why typeof and the global isNaN() let bad values through, how to validate numeric strings from forms, and how to write a TypeScript type guard.
Filter an array of objects by property in TypeScript with filter(): single and multiple conditions, lists of values, nested and optional fields, a typed filterBy() helper and type narrowing.
A callback function in TypeScript is a function passed to another function and called later. Examples cover callback types, passing parameters, error-first callbacks, Promises and async/await.
Function overloading in TypeScript gives one function several call signatures and a single implementation. Examples cover classes, constructors, call signatures and the simpler alternatives.
A rest parameter collects any number of arguments into one typed array, and a spread argument expands an array back into arguments. Examples cover function types, tuples and typed wrappers.
How template strings work in TypeScript: placeholders and expressions, multi-line text, tagged templates and String.raw, and template literal types that check string patterns at compile time.
A TypeScript Set stores unique values in insertion order. Create one, add and check values, remove duplicates from arrays, and compare sets with the ES2025 methods.
TypeScript Map with tested examples: create, update and iterate entries, handle undefined from get(), convert to JSON, sort, and choose Map vs Record.
The classic for loop, for…of, for…in and forEach() in TypeScript, with break, continue, labels, and iteration over Map, Set and object entries.
What each tsconfig.json option does, the real tsc –init output of TypeScript 7.0.2, three stricter options worth enabling, and the old options TypeScript 7 removed.
Literal types restrict a value to an exact list such as “small” | “medium” | “large”. Learn widening, as const, deriving unions from arrays, checking user input and Record lookups.
Numeric, string and const enums in TypeScript, reverse mapping and string-to-enum conversion, plus why Node.js type stripping and erasableSyntaxOnly reject enums and what to use instead.
How to declare, type, read, loop over, copy and protect arrays in TypeScript, with tuples and the ES2023 copying methods, tested on TypeScript 7.0 and Node.js 22.
undefined means a value was never set, null means it was set to “nothing” on purpose. Learn where each comes from, how they differ, and how strictNullChecks, ?? and ?. handle them.
How TypeScript union types work, how to narrow them with typeof, instanceof, in and type guards, and how discriminated unions with an exhaustive switch catch forgotten cases.
The difference between == and === in TypeScript with real results, the type conversion rules of ==, the compiler checks, and the one accepted use of == null.
How the three dots copy and merge arrays and objects, pass arguments and collect rest values in TypeScript, with tested examples and the compiler errors that go with them.
How &&, || and ! short-circuit and return operands in TypeScript, when to use ?? instead of ||, optional chaining, logical assignment, and the compiler checks for always-truthy conditions.
How ===, !==, <, >, <= and >= behave in TypeScript for numbers, strings, dates and objects, and which comparisons the compiler rejects.
An overview of the TypeScript type system: primitive types, inference, any vs unknown vs never, arrays and tuples, object types, unions and generics, with examples tested on TypeScript 7.0.2.
Install TypeScript 7 with npm, compile a first program with tsc, set up tsconfig.json, and run .ts files directly with Node.js 22 type stripping.
Every TypeScript arithmetic operator with real results, plus the cases that surprise beginners: decimal division, negative remainders, ** and the compiler errors for strings and unions.
var is function-scoped, let and const are block-scoped, and const cannot be reassigned. Examples cover the temporal dead zone, loop closures, const objects and TypeScript literal types.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.