Open this example in the interactive library
Source code
type Config = {
mode: "dev" | "prod";
retries: number;
tags: readonly string[];
};
const defaults: Config = { mode: "dev", retries: 2, tags: ["api"] };
console.log(
(({ mode, tags }: Config): Pick<Config, "mode" | "tags"> => ({ mode, tags }))(
defaults,
),
);
Sample output
{ mode: 'dev', tags: [ 'api' ] }