DEV Community

Discussion on: TypeScript Basics - A Definitive Guide

khylias profile image
Vincent Kraus • Edited on

Nice one !
I recommand you to use const rather than let if you didn't reassign variable as :

const createNewArray = <T>(value: T): Array<T> => {
    const output : Array<string> = [];


    return output;

And last tips, you can declare type array as below for an array of string.

const output: string[] = []; // Array of string
const output2: number[]; // Array of number, etc...
ganeshmani profile image
GaneshMani Author

Sure.. will change it..thanks for the heads up.. :-)