CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tsconfig--node14

A base TSConfig for working with Node 14.

84

1.05x
Overview
Eval results
Files

task.mdevals/scenario-10/

Multi-Environment TypeScript Configuration Tool

Create a command-line tool that generates appropriate TypeScript configuration files for different runtime environments based on user input. The tool should properly configure environment-specific type definitions and library declarations.

Requirements

Your tool should accept a target environment as a command-line argument and generate a tsconfig.json file with the appropriate type definitions for that environment.

Supported Environments

  1. browser - Web browser environment
  2. node - Node.js LTS environment
  3. testing - Testing framework environment (e.g., for tools like Cypress or Jest)

Configuration Rules

For each environment, the generated tsconfig.json should include:

Browser Environment:

  • Include DOM and DOM-related type definitions
  • Target modern ECMAScript features
  • Enable strict mode for type safety

Node Environment:

  • Include appropriate ECMAScript library for Node.js
  • Use Node.js module resolution
  • Enable strict mode for type safety

Testing Environment:

  • Include minimal ES library (ES5 for maximum compatibility)
  • Specify testing framework types explicitly
  • Enable strict mode for type safety

Command-Line Interface

# Generate browser configuration
node src/config-generator.js browser

# Generate Node configuration
node src/config-generator.js node

# Generate testing configuration
node src/config-generator.js testing

The tool should write the generated configuration to tsconfig.json in the current directory.

Error Handling

  • If no environment is specified, display usage information
  • If an unsupported environment is specified, show an error and list valid options
  • Overwrite existing tsconfig.json if it exists

@generates

Test Cases

  • When run with "browser" argument, generates a tsconfig.json with DOM type libraries @test
  • When run with "node" argument, generates a tsconfig.json with Node-appropriate ES libraries @test
  • When run with "testing" argument, generates a tsconfig.json with testing framework types @test
  • When run with no arguments, displays usage information @test
  • When run with invalid environment, shows error message @test

Dependencies { .dependencies }

@tsconfig/bases { .dependency }

Provides standardized TypeScript configuration bases for different runtime environments.

Install with Tessl CLI

npx tessl i tessl/npm-tsconfig--node14

tile.json