{"library":"mrm-task-typescript","title":"Mrm TypeScript Task","description":"mrm-task-typescript is an Mrm task designed to automate the initial setup and configuration of TypeScript within a JavaScript project. It currently stands at version 4.1.22. As part of the Mrm monorepo, its releases are often coordinated with other Mrm tasks, typically seeing version bumps (sometimes 'bump only') to ensure compatibility across the Mrm ecosystem. This task distinguishes itself by providing a declarative and automated way to standardize TypeScript configuration across multiple projects or within an organization, reducing manual setup errors and ensuring best practices are applied consistently. It handles the creation of `tsconfig.json`, integrates a type-checking script into `package.json`, and installs necessary TypeScript-related dependencies, streamlining the developer workflow for adopting TypeScript.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mrm-task-typescript"],"cli":{"name":"mrm","version":null}},"imports":["npx mrm typescript","npx mrm typescript","npx mrm typescript"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as path from 'path';\nimport * as fs from 'fs';\nimport { execSync } from 'child_process';\n\nconst projectName = 'my-ts-project';\nconst projectPath = path.join(process.cwd(), projectName);\n\nconsole.log(`Creating project directory: ${projectPath}`);\nfs.mkdirSync(projectPath, { recursive: true });\nprocess.chdir(projectPath);\n\nconsole.log('Initializing npm...');\nexecSync('npm init -y', { stdio: 'inherit' });\n\nconsole.log('Running mrm typescript task...');\nexecSync('npx mrm typescript', { stdio: 'inherit' });\n\nconsole.log('\\nVerifying setup:');\nconsole.log('Content of tsconfig.json:');\nconsole.log(fs.readFileSync('tsconfig.json', 'utf8'));\n\nconsole.log('\\nContent of package.json scripts:');\nconst packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));\nconsole.log(packageJson.scripts);\n\n// Create a sample TypeScript file to demonstrate compilation\nfs.mkdirSync('src', { recursive: true });\nfs.writeFileSync('src/index.ts', `\nfunction greet(name: string): string {\n  return \\`Hello, \\${name}!\\`;\n}\nconsole.log(greet(\"TypeScript User\"));\n`);\n\nconsole.log('\\nAttempting to run type check script...');\nexecSync('npm run typecheck', { stdio: 'inherit' });\n\nconsole.log('\\nTypeScript setup complete! To clean up, run:');\nconsole.log(`rm -rf ${projectName}`);","lang":"typescript","description":"Demonstrates how to create a new project, initialize npm, and apply the `mrm typescript` task to configure TypeScript, including `tsconfig.json` and a type-checking script.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}