Suppose an array is declared as follows:
const array = ['a', 'b', 'c'];
The type of this array would be string[]
. Is there a way to automatically determine the type based on the content, so that there is no need to specify the content again in the type definition of array
? For example:
const array: ['a', 'b', 'c'] = ['a', 'b', 'c'];