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.
npm install typescript-cpVerified import paths — ran on the pinned version, not inferred.
Demonstrates `typescript-cp` integration into `package.json` scripts for both build and watch modes, running alongside `tsc`.
Consult the changelog (`https://github.com/body-builder/typescript-cp/releases`) for breaking changes before updating to a new minor version.
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`).
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.
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.
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).
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.
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.