Skip to main content

TypeScript Support


Kosko and kubernetes-models are written in TypeScript, so you don't have to install any additional type declaration files.


To start using TypeScript, you have to either add require option in kosko.toml, or run Kosko with -r/--require option.

require = ["ts-node/register"]

Environment Types#

You can specify types of environment variables by extending type declarations of @kosko/env module.

import * as env from "@kosko/env";
// Declare types for global environment variablesdeclare interface GlobalEnvironment {  imageRegistry: string;}
// Declare types for component environment variablesdeclare interface ComponentEnvironment {  // Fallback type of all other component variables which are not specified below  [key: string]: unknown;
  // Specify types for each component  nginx: {    replicas: number;  };}
// Extend type declarations of "@kosko/env" moduledeclare module "@kosko/env" {  // Extend Environment interface  interface Environment {    global(): GlobalEnvironment;
    component<K extends string>(      name: K    ): GlobalEnvironment & ComponentEnvironment[K];  }}