Reproduction
A constructor or Handler has parameters, but the compiled output contains neither design-time parameter metadata nor an explicit @Inject() token:
import { Command, Handler, Injectable, Module, createApp } from 'func'
@Injectable()
class ProjectService {}
@Command('inspect')
class InspectCommand {
constructor(private project: ProjectService) {}
@Handler()
run() {}
}
@Module({
commands: [InspectCommand],
providers: [ProjectService],
})
class AppModule {}
createApp(AppModule)What this error means
func knows the parameter position but cannot determine which token to request from the DI container. details.target identifies the class or method, and details.index gives the parameter position.
How to fix it
For class-type injection, enable decorators and parameter metadata in the TypeScript configuration used by the actual build:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}Use an explicit token for interfaces, type-only dependencies, or parameters that should not depend on reflection metadata:
import { Inject, createToken } from 'func'
interface Project {
name: string
}
const PROJECT = createToken<Project>('PROJECT')
class InspectCommand {
constructor(@Inject(PROJECT) private project: Project) {}
}Whichever approach you use, register the corresponding Provider in the current Module and ensure imported Providers are exported explicitly.