You can use a const assertion:
['List', 'Of', 'Names']
.map((name, index) => [name, index % 2] as const) // insert `as const` here
.map(([name, num]) => { }); // name: string, num: number
Take a look at the playground sample.
More Related Contents:
- ‘unknown’ vs. ‘any’
- TypeScript function overloading
- typescript interface require one of two properties to exist
- How to pass optional parameters while omitting some other optional parameters?
- How do you produce a .d.ts “typings” definition file from an existing JavaScript library?
- Angular 2 Show and Hide an element
- Typescript Interface – Possible to make “one or the other” properties required?
- Difference between ‘object’ ,{} and Object in TypeScript
- Forcing excess-property checking on variable passed to TypeScript function
- Why can Typescript not figure out the type in my code?
- How to reject in async/await syntax?
- How to overwrite incorrect TypeScript type definition installed via @types/package
- TypeScript TS7015 error when accessing an enum using a string type parameter
- Property ‘includes’ does not exist on type ‘string[]’
- Typescript: Type ‘string | undefined’ is not assignable to type ‘string’
- Typescript: Cannot use import statement outside a module
- Angular2 – Share data between components using services
- ‘this’ implicitly has type ‘any’ because it does not have a type annotation
- TypeScript class implements class with private functions
- Using jQuery plugin in TypeScript
- how to debug typescript files in visual studio code
- Is there a way to create nominal types in TypeScript that extend primitive types?
- How should I use @types with TypeScript 2
- TypeScript interfaces not enforcing properties when an object is assigned
- Can I reuse the parameter definition of a function in Typescript?
- Iterable cannot confirm generic T in function
- How to import all modules from a directory in TypeScript?
- What means “ambient” in TypeScript
- Angular2 HTTP GET – Cast response into full object
- TypeScript keyof index type is too wide