Skip to content

Instantly share code, notes, and snippets.

@thoroc
Created July 21, 2023 10:50
Show Gist options
  • Save thoroc/004af06e0358884a40f626345d8a75ce to your computer and use it in GitHub Desktop.
Save thoroc/004af06e0358884a40f626345d8a75ce to your computer and use it in GitHub Desktop.
Merging string[] in Typescript
interface MyOptions {
dirs: string[];
length?: number;
yaml?: boolean;
name?: string;
}
const options1: MyOptions = {
dirs: ['src', 'test'],
length: 88,
yaml: true,
}
console.log(options1);
const options2: MyOptions = {
dirs: ['lib']
}
console.log(options2);
console.log({ ...options1, ...options2 });
console.log({ ...options2, ...options1 });
const options3: MyOptions = {
dirs: ['bin', 'lib'],
name: 'options3'
}
console.log(options3);
console.log({ ...options1, ...options3 });
console.log({ ...options3, ...options1 });
const plugins = [
'plugin:import/typescript',
'prettier',
'plugin:prettier/recommended',
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'prettier'
];
console.log(plugins);
console.log([...new Set(plugins)]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment