Skip to content

Dynamic Configuration

TypeScript

Instead of knip.json, you can use a TypeScript file (knip.ts) 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

For special cases you can export an async function:

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