Skip to content

Dynamic Configuration

TypeScript

Instead of a JSON file, you can use a JavaScript or TypeScript file for a dynamic configuration and type annotations:

knip.ts
import type { KnipConfig } from 'knip';
const config: KnipConfig = {
entry: ['src/index.ts'],
project: ['src/**/*.ts'],
};
export default config;

Function

You can export a regular or async function that returns the configuration object as well:

knip.ts
import type { KnipConfig } from 'knip';
const config = async (): Promise<KnipConfig> => {
const items = await fetchRepoInfo();
return {
entry: ['src/index.ts', ...items],
project: ['src/**/*.ts'],
};
};
export default config;

ISC License © 2024 Lars Kappert