Created
December 20, 2019 09:40
-
-
Save RubaXa/bc844145596417a8a49dd3c1b24c776c to your computer and use it in GitHub Desktop.
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
// 1. Это вариант предпочтительней | |
function convertTupleToObject<T extends any[]>(...tuple: T) { | |
// ... | |
} | |
// vs | |
// 2. чем этот | |
function convertArrayToObject<T extends any[]>(array: T) { | |
// ... | |
} | |
// ибо использование (1) выглядит аккуратнее | |
let good = convertTupleToObject({id: 1}, {id: 2}, {id: 3}); | |
// чем вариант (2), притом про <const> нельзя забывать | |
let poor = convertArrayToObject(<const>[{id: 1}, {id: 2}, {id: 3}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment