Is Tuple union type still work?
Opened this issue · 3 comments
xiaojingzhao commented
On http://www.typescriptlang.org/docs/handbook/basic-types.html , It said
When accessing an element outside the set of known indices, a union type is used instead
However, when I tested this example locally, both tsc
and deno
threw an error:
Type '"some string here"' is not assignable to type 'undefined'
Here is the example:
let x: [string, number];
x = ["hello", 10];
console.log('x[0].substr(1)', x[0].substr(1));
x[2] = 'world'; // Error was threw here
ApolloTang commented
microsoft/TypeScript#28894 (comment)
according to that comment tuples is now fixed length
xiaojingzhao commented
Microsoft/TypeScript#28894 (comment)
according to that comment tuples is now fixed length
Copy~thanks