{"id":12227,"library":"typescript-cp","title":"TypeScript Copy Non-TS Files","description":"typescript-cp is a utility designed to seamlessly copy non-TypeScript asset files into a TypeScript project's `outDir` during the build or watch process. It currently stands at version 0.1.9, indicating it's still in active development with minor releases for features and bug fixes, rather than a strict major-version-based cadence. Its core functionality integrates directly with TypeScript's project structure, honoring `tsconfig.json` configurations, particularly the `exclude` array, to prevent copying files that TypeScript itself ignores. Key differentiators include its CLI-first approach, ability to watch files for changes alongside `tsc -w`, and support for loader rules to transform asset content before copying, providing a more integrated solution than generic file copy utilities for TypeScript-specific workflows.","status":"active","version":"0.1.9","language":"javascript","source_language":"en","source_url":"https://github.com/body-builder/typescript-cp","tags":["javascript","typescript","ts","file","asset","copy","watch","watcher","watchfile"],"install":[{"cmd":"npm install typescript-cp","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-cp","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-cp","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for interacting with TypeScript project configurations and APIs.","package":"typescript","optional":false}],"imports":[{"note":"Used for type-checking the configuration file (`.tscprc.js`) when defining custom loader rules. This is a type import, not a runtime value.","symbol":"Config","correct":"import { Config } from 'typescript-cp/dist/types';"},{"note":"Used for type-checking individual rule definitions within the `.tscprc.js` configuration. This is a type import, not a runtime value.","symbol":"Rule","correct":"import { Rule } from 'typescript-cp/dist/types';"},{"note":"The primary way to use `typescript-cp` is via its Command Line Interface (`tscp`), typically invoked with `npx` or as an npm script. It is not designed for direct programmatic import as a library.","wrong":"import tscp from 'typescript-cp';","symbol":"tscp (CLI)","correct":"npx tscp"}],"quickstart":{"code":"{\n  \"name\": \"my-ts-project\",\n  \"version\": \"1.0.0\",\n  \"description\": \"A sample project using typescript-cp\",\n  \"main\": \"dist/index.js\",\n  \"scripts\": {\n    \"clean\": \"rm -rf dist\",\n    \"build:ts\": \"tsc\",\n    \"build:assets\": \"tscp\",\n    \"build\": \"npm run clean && npm run build:ts && npm run build:assets\",\n    \"watch:ts\": \"tsc -w\",\n    \"watch:assets\": \"tscp -w\",\n    \"start:dev\": \"npm run clean && npm run watch:ts & npm run watch:assets\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"typescript\": \">=4.2.3\",\n    \"typescript-cp\": \"^0.1.9\"\n  },\n  \"private\": true\n}\n\n// To run the build:\n// npm run build\n\n// To start the dev watcher:\n// npm run start:dev","lang":"json","description":"Demonstrates `typescript-cp` integration into `package.json` scripts for both build and watch modes, running alongside `tsc`."},"warnings":[{"fix":"Consult the changelog (`https://github.com/body-builder/typescript-cp/releases`) for breaking changes before updating to a new minor version.","message":"The package is still pre-1.0 (currently 0.1.9), meaning minor versions (e.g., 0.x.x to 0.y.x) *can* introduce breaking changes without adhering to semantic versioning for major increments. Always review release notes when updating.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure your `typescript` peer dependency is compatible. If experiencing issues, update `typescript-cp` to the latest version and verify your `typescript` version meets the peer dependency requirements (currently `>=4.2.3`).","message":"Support for TypeScript 5 was introduced in v0.1.8. While this generally means improved compatibility, older versions of `typescript-cp` might not function correctly with TypeScript 5+, and conversely, newer versions might drop support for very old TypeScript versions.","severity":"breaking","affected_versions":">=0.1.8"},{"fix":"Check your `tsconfig.json` `exclude` array. For fine-grained control, configure `use_ts_exclude` to `false` or adjust `ignored_files` in a `.tscprc` configuration file. Refer to the documentation on configuration options.","message":"By default, `typescript-cp` respects the `exclude` array in your `tsconfig.json`. If files are not being copied as expected, verify they are not inadvertently listed in `exclude` or being ignored by default `ignored_files` patterns (e.g., `node_modules`).","severity":"gotcha","affected_versions":">=0.1.4"},{"fix":"Ensure custom loaders are simple, synchronous functions that accept content and meta-data, returning the transformed content. For more complex asset pipelines, consider pre-processing files with dedicated tools before `typescript-cp` handles them.","message":"The package provides basic loader functionality for transforming file content. These loaders are defined in a `.tscprc.js` file and must return the modified content synchronously. Complex or asynchronous transformations are not directly supported within the loader function.","severity":"gotcha","affected_versions":">=0.1.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Increase your system's `fs.inotify.max_user_watches` limit (Linux: `sudo sysctl -n -w fs.inotify.max_user_watches=524288`) or refine your `.tscprc` configuration to `exclude` more directories/files, especially `node_modules` (which is ignored by default but can be overridden).","cause":"Too many files are being watched, hitting the operating system's limit for open file descriptors.","error":"Error: watch ENOSPC"},{"fix":"Ensure `typescript-cp` is installed as a `devDependency` (`npm install typescript-cp -D`). Verify your `tsconfig.json` `moduleResolution` is set appropriately (e.g., `NodeNext` or `Node`). If using an older TypeScript version, ensure it is compatible with the package's type declarations.","cause":"Attempting to import types from `typescript-cp` in a TypeScript environment, but the package or its types are not correctly installed or resolved.","error":"Error: Cannot find module 'typescript-cp/dist/types' or its corresponding type declarations."},{"fix":"First, check your `tsconfig.json` `exclude` array. Next, inspect your `.tscprc` file (if present) for `ignored_files` and `compiled_files` patterns. You can also run `tscp` with verbose logging (if available, check help `tscp -h`) or temporarily remove exclusion patterns to diagnose.","cause":"This often occurs because files are matched by the `tsconfig.json`'s `exclude` array, the `.tscprc`'s `ignored_files` or `compiled_files` patterns, or the source/destination paths are incorrectly configured.","error":"Files are not being copied to outDir."}],"ecosystem":"npm"}