type-expand
v1.0.0
Published
Utilities to expand TypeScript types shown by IntelliSense in Visual Studio Code.
Downloads
178
Maintainers
Readme
type-expand
Utilities to expand TypeScript types shown by IntelliSense in Visual Studio Code.
Inspired by https://stackoverflow.com/a/57683652.
Installation
npm install --save-dev type-expand
Usage
Commented lines are the results shown in hover info when your cursor hovers over the types.
import type { Expand, ExpandDeep } from "type-expand";
type FooError = { foo: Error };
type BarError = { bar: Error };
type FooBarError = FooError & BarError;
// type FooBarError = FooError & BarError;
type ExpandedFooBarError = Expand<FooBarError>;
// type ExpandedFooBarError = {
// foo: Error;
// bar: Error;
// };
type DeepExpandedFooBarError = ExpandDeep<FooBarError>;
// type DeepExpandedFooBarError = {
// foo: {
// name: string;
// message: string;
// stack?: string;
// };
// bar: {
// name: string;
// message: string;
// stack?: string;
// };
// };
Unlike other utility types, Expand
and ExpandDeep
do not transform type in any way.