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-7/

TypeScript Module Configuration Generator

Overview

Create a utility that generates appropriate TypeScript module system configurations for different project types. The tool should produce configuration objects with the correct module and moduleResolution settings based on the target environment.

Requirements

Part 1: Configuration Generator

Implement a function generateModuleConfig(projectType: string) that creates TypeScript configurations:

  1. Input: A project type string (one of: "legacy-node", "modern-node", "bundler")

  2. Output: A configuration object containing:

    • module compiler option
    • moduleResolution compiler option
  3. Configuration Rules:

    • legacy-node: For Node.js projects using CommonJS modules
    • modern-node: For Node.js projects with ESM support
    • bundler: For projects using modern build tools

Part 2: Configuration Validator

Implement a function validateModuleConfig(config: object) that checks compatibility:

  1. Input: A configuration object with module and moduleResolution properties
  2. Validation: Verify that the settings are compatible with each other
  3. Output: Return an object with:
    • valid: boolean indicating if configuration is compatible
    • message: string explaining the result

Part 3: Test Cases { .test }

Create test cases in module-config.test.ts:

Test 1: Generate legacy Node.js configuration @test

const config = generateModuleConfig("legacy-node");
// Verify config has appropriate module and moduleResolution settings for CommonJS

Test 2: Generate modern Node.js configuration @test

const config = generateModuleConfig("modern-node");
// Verify config has appropriate module and moduleResolution settings for ESM

Test 3: Validate compatible configuration @test

const result = validateModuleConfig({ module: "commonjs", moduleResolution: "node" });
// Expect result.valid to be true

Dependencies { .dependencies }

@tsconfig/node14 { .dependency }

Provides a base TypeScript configuration for Node.js 14, serving as a reference for module system configuration patterns.

Implementation Notes

  • Focus on correctness of module and moduleResolution pairings
  • Ensure the generated configurations follow TypeScript best practices
  • Validation should provide clear feedback about what's wrong
  • Keep the API simple and easy to use

File Structure

module-config.ts          # Main implementation
module-config.test.ts     # Test cases

Install with Tessl CLI

npx tessl i tessl/npm-tsconfig--node14

tile.json