{"id":10426,"library":"typescript","title":"TypeScript","description":"TypeScript is a superset of JavaScript that adds optional static typing, enabling robust tools for large-scale application development across any browser, host, or OS. The current stable version is 6.0.3. New stable versions are typically released every few months, preceded by beta and release candidate versions, ensuring a predictable upgrade path.","status":"active","version":"6.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/microsoft/TypeScript","tags":["javascript","TypeScript","Microsoft","compiler","language","typescript"],"install":[{"cmd":"npm install typescript","lang":"bash","label":"npm"},{"cmd":"yarn add typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This import is for programmatic access to the TypeScript compiler API (e.g., for build tools or language services), not for runtime use in applications.","symbol":"ts","correct":"import * as ts from 'typescript';"}],"quickstart":{"code":"npm install -D typescript\n\n// Create a file named 'hello.ts'\n// console.log(`\n// function greet(name: string) {\n//   console.log(`Hello, ${name}!`);\n// }\n// \n// greet(\"World\");\n// greet(123); // This will cause a TypeScript error\n// `);\n\n// Compile the TypeScript file\nnpx tsc hello.ts\n\n// Run the compiled JavaScript file\nnode hello.js","lang":"typescript","description":"Installs the TypeScript compiler, creates a sample TypeScript file, compiles it to JavaScript using the `tsc` command, and then executes the resulting JavaScript file."},"warnings":[{"fix":"Review the official TypeScript blog announcements (e.g., devblogs.microsoft.com/typescript) for detailed breaking changes and migration guides specific to your upgrade path.","message":"Major versions of TypeScript can introduce breaking changes to the language, compiler options, or API. Always consult the release notes before upgrading.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Prefer installing TypeScript as a development dependency (`npm install -D typescript`) within each project and use `npx tsc` or npm/yarn scripts (e.g., `\"build\": \"tsc\"`) to ensure the correct project-local compiler is used.","message":"Installing TypeScript globally (`npm install -g typescript`) can lead to version mismatches with project-local TypeScript installations, causing unexpected compilation behavior.","severity":"gotcha","affected_versions":"All"},{"fix":"Add `\"strict\": true` to your `compilerOptions` in `tsconfig.json`. Consider enabling other strict flags incrementally if full strict mode is too aggressive initially.","message":"TypeScript's default configuration in `tsconfig.json` can be permissive. For robust type checking and to catch common errors, strict mode is highly recommended.","severity":"gotcha","affected_versions":"All"},{"fix":"Upgrade your Node.js environment to version 14.17.0 or higher. Use a Node.js version manager like `nvm` to easily switch between versions.","message":"TypeScript requires a minimum Node.js version of 14.17.0. Using older Node.js versions may result in installation errors or unexpected compiler behavior.","severity":"breaking","affected_versions":"<14.17.0"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"For third-party JavaScript libraries, install their type definitions (e.g., `npm install -D @types/library-name`). Ensure your `tsconfig.json` `moduleResolution` is correctly configured (e.g., `\"node\"` or `\"bundler\"`).","cause":"The TypeScript compiler cannot locate the module you are trying to import, or it's missing type definition files (`.d.ts`) for a JavaScript library.","error":"TS2307: Cannot find module '...' or its corresponding type declarations."},{"fix":"Verify that the property truly exists on the object. If it's a known property from a less-typed source, use a type assertion (e.g., `(myObject as any).X`) or add a type guard to narrow the type (e.g., `if ('X' in myObject)`).","cause":"You are attempting to access a property (`X`) that is not declared on the type (`Y`) of the object.","error":"TS2339: Property 'X' does not exist on type 'Y'."},{"fix":"Review the function's signature and provide the correct number of arguments. If some arguments are optional, ensure they are handled correctly.","cause":"A function or method is being called with an incorrect number of arguments, not matching its defined signature.","error":"TS2554: Expected X arguments, but got Y."},{"fix":"Set `\"experimentalDecorators\": true` within the `compilerOptions` section of your `tsconfig.json` file. Note that these are experimental and may change in future TypeScript versions.","cause":"You are using JavaScript decorators (Stage 3 proposal) in your code without enabling the `experimentalDecorators` compiler option.","error":"TS1206: Decorators are not supported if 'experimentalDecorators' is set to 'false'."}],"ecosystem":"npm"}