Last active
December 20, 2019 09:34
-
-
Save RubaXa/15c379a94864eb50dae97b69e3e40d80 to your computer and use it in GitHub Desktop.
Tuple vs. <const>
This file contains hidden or 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
let tuple = createTuple('foo', true, { bar: 2019 }); | |
// 1. readonly [string, boolean, { bar: number }] | |
let constArray = <const>['foo', true, { bar: 2019 }]; | |
// 2. readonly [string, boolean, { bar: number }] | |
let justArray = ['foo', true, { bar: 2019 }]; | |
// 3. (string | boolean | { bar: number }) | |
function createTuple<T extends any[]>(...args: T): Readonly<T> { | |
return args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment