How to Declare an Empty Array in TypeScript? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report TypeScript provides a robust type system that allows you to define and manage data structures more effectively than in plain JavaScript. One common task is declaring empty arrays with specific types, ensuring that your array holds only values of the intended type. These are the following ways to declare an empty array in TypeScript:Table of ContentDeclaring an Empty Array of a Specific TypeDeclaring an Array That Can Hold Multiple TypesDeclaring an Empty Array of a Specific TypeIn TypeScript, you can declare an empty array that will only accept elements of a particular type. The most common approach is using the square bracket syntax to specify the type of the array. This ensures that only numbers can be added to the numbers array. Trying to add a value of a different type (e.g., a string) will result in a compilation error.Example: In this example, we will declare an empty array of numbers that can only hold numbers. JavaScript let numbers: number[] = []; numbers.push(1); numbers.push(2); console.log(numbers); // Output: [1, 2] Output:[1, 2]Declaring an Array That Can Hold Multiple TypesSometimes you may need an array that can store values of different types. TypeScript allows you to use union types to declare such arrays. This approach is useful when you need a flexible array that can store different types of data, but you still want the type safety provided by TypeScript.Example: In this example, the array can hold both numbers and strings. JavaScript let mixedArray: (number | string)[] = []; mixedArray.push(1); mixedArray.push("Hello"); console.log(mixedArray); // Output: [1, "Hello"] Output:[1, "Hello"] Comment More infoAdvertise with us Next Article Must Coding Questions - Company-wise S sharmasahtqzx Follow Improve Article Tags : Web Technologies TypeScript Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like