Skip to content

@getkist/action-typescript

TypeScript compilation with full tsconfig.json support.

Installation

bash
npm install --save-dev @getkist/action-typescript

Actions

TypeScriptCompilerAction

Compiles TypeScript files to JavaScript.

Options

OptionTypeDefaultDescription
tsconfigstring"tsconfig.json"Path to tsconfig.json
projectstring-Alternative to tsconfig
outDirstring-Override output directory
declarationboolean-Generate .d.ts files
sourceMapboolean-Generate source maps
watchbooleanfalseWatch mode

Basic Usage

yaml
plugins:
  - @getkist/action-typescript

pipeline:
  build:
    stages:
      - name: compile
        steps:
          - action: TypeScriptCompilerAction
            options:
              tsconfig: tsconfig.json

With Options Override

yaml
- action: TypeScriptCompilerAction
  options:
    tsconfig: tsconfig.json
    outDir: dist/js
    declaration: true
    sourceMap: true

Multiple Configurations

yaml
pipeline:
  build:
    stages:
      - name: compile
        steps:
          # Build main library
          - action: TypeScriptCompilerAction
            options:
              tsconfig: tsconfig.lib.json
              outDir: dist/lib
              
          # Build CLI
          - action: TypeScriptCompilerAction
            options:
              tsconfig: tsconfig.cli.json
              outDir: dist/cli

tsconfig.json Example

json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "Node",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "outDir": "dist",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

With Linting

Lint before compiling:

yaml
plugins:
  - @getkist/action-eslint
  - @getkist/action-typescript

pipeline:
  build:
    stages:
      - name: lint
        steps:
          - action: LintAction
            options:
              files: ["src/**/*.ts"]
              
      - name: compile
        steps:
          - action: TypeScriptCompilerAction
            options:
              tsconfig: tsconfig.json

Output Structure

With default settings:

src/
├── index.ts
├── lib/
│   └── utils.ts

# Compiles to:
dist/
├── index.js
├── index.js.map
├── index.d.ts
├── lib/
│   ├── utils.js
│   ├── utils.js.map
│   └── utils.d.ts

Error Handling

TypeScript errors are reported with full diagnostic information:

src/index.ts(15,3): error TS2339: Property 'foo' does not exist on type 'Bar'.

The action fails if there are any compilation errors.

Released under the MIT License.