TypeScript

Keyof for Nested Objects

Problem interface User { parent: { name: string; }; age: number; name: string; } type Column = { key: keyof User; }; const columns: Column[] = [ { key: 'name' }, { key: 'name1' }, { key:'parent.name' } ]; Solution type Paths<T> = T extends object ? { [K in keyof T]: `${Exclude<K, symbol>}${"" | `.${Paths<T[K]>}`}` }[keyof T] : never type Column = { key: Paths<User>; }; In addition to writing your own Paths type, you can also use existing libraries, such as the Path type from type-fest.

Jul 22, 2025

Writing TypeScript in Monaco Editor

This article introduces how to write TypeScript in Monaco Editor, including the advantages, implementation details, and related resources. These steps can help improve your efficiency when working with TypeScript in Monaco Editor.

Jan 20, 2024

Global Type Definition Issues in Third-party Packages

When global types in third-party packages don't apply, here’s how to wire them up in TS or JS projects and the ideal @types approach.

Apr 5, 2022

Add Global Constants to a Frontend Project

Expose config from package.json into the built app via webpack DefinePlugin, with typing in TS and pitfalls to avoid.

Jan 25, 2022

Contributing TS Type Declarations to Open Source Projects

How to create, package, and reference TypeScript declaration files when contributing typings to open-source projects.

Sep 12, 2021

Lesser-Known TypeScript Types

Covers `never`, `ArrayLike`, and `PromiseLike`, when to use them, and links to further reading.

Sep 5, 2021

Extend AxiosRequestConfig in TypeScript

Use declaration merging to add custom properties (e.g., loading flags) to AxiosRequestConfig without sacrificing type safety.

Jan 11, 2021

TypeScript Enum vs. ES6 Symbol

Compares TypeScript enums and ES6 symbols so you know when to choose each for identifiers and constants.

Dec 2, 2020

Understanding TypeScript

Key takeaways about TypeScript, including use cases and implementation details, to help you work with the language more effectively.

Nov 10, 2020

Upgrading TypeScript to v4

Notes from upgrading to TypeScript 4.0—packages to bump, issues encountered, and fixes.

Oct 21, 2020