Created
July 21, 2023 10:50
-
-
Save thoroc/004af06e0358884a40f626345d8a75ce to your computer and use it in GitHub Desktop.
Merging string[] in Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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