CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-swc--core-darwin-arm64

Platform-specific native binary for SWC TypeScript/JavaScript compiler on macOS ARM64 architecture

89

1.15x
Overview
Eval results
Files

task.mdevals/scenario-7/

Decorator Code Transformer

Build a CLI tool that transforms TypeScript files containing decorators from legacy syntax to modern syntax using a compiler tool.

Requirements

Your tool should accept a TypeScript file path as input and output the transformed code. The tool must handle both class decorators and method decorators appropriately.

Input Format

The input will be a TypeScript file containing classes with legacy decorators. For example:

function Logger(target: any) {
  console.log('Class created:', target.name);
}

function Validate(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
  const original = descriptor.value;
  descriptor.value = function(...args: any[]) {
    console.log('Validating...');
    return original.apply(this, args);
  };
}

@Logger
class UserService {
  @Validate
  createUser(name: string) {
    return { name };
  }
}

Output Requirements

  1. Transform the code to target ES2022 (or a modern ECMAScript version)
  2. Apply appropriate decorator transformations based on the configured decorator version
  3. Preserve the original functionality and structure of the code
  4. Output the transformed JavaScript code to stdout

Command Line Interface

Your tool should be invoked as:

node transform.js <input-file-path>

Test Cases

  • Given a file with a class decorator, the tool outputs transformed code that maintains the decorator's behavior @test
  • Given a file with method decorators, the tool correctly transforms all method decorators @test
  • Given a file with both class and method decorators, all decorators are transformed appropriately @test

Implementation

@generates

Dependencies { .dependencies }

@swc/core { .dependency }

Provides high-performance TypeScript/JavaScript compilation and transformation capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-swc--core-darwin-arm64

tile.json