npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thoughtspot/ts-to-any

v0.0.1

Published

A tool to convert TypeScript types to other programming languages.

Readme

TypeScript to Any Converter

A tool to convert TypeScript types to other programming languages.

Usage

Basic Usage

import {
  TypeScriptConverter,
  createDartConversionConfig,
  Configs,
} from "@thoughtspot/ts-to-any";
import path from "path";

// Option 1: Using Dart-specific config
const converter1 = new TypeScriptConverter({
  conversionConfig: createDartConversionConfig({
    templateRootPath: path.resolve("templates", "dart"),
    useJsonSerializable: true, // Enable JSON serialization support
  }),
  inputConfig: {
    inputFiles: ["src/types.ts", "src/css-variables.ts"],
  },
  logLevel: "Info", // Optional: Set logging level
});

// Option 2: Using default configs
const converter2 = new TypeScriptConverter({
  conversionConfig: Configs.dart,
  inputConfig: {
    inputFiles: ["src/types.ts", "src/css-variables.ts"],
  },
});

// Convert and write to file
const result = converter1.convertAndWriteToFile({
  outPutFile: "types.dart",
});

console.log(result);

Exporting Default Configs

You can export and reuse default configurations in your project. Here's how to set it up:

  1. Create a config file (e.g., config.ts):
import {
  createDartConversionConfig,
  Configs as DefaultConfigs,
} from "@thoughtspot/ts-to-any";
import path from "path";

// Option 1: Extend default Dart configuration
export const dartConfig = createDartConversionConfig({
  ...DefaultConfigs.dart,
  templateRootPath: path.resolve("templates", "dart"),
  useJsonSerializable: true,
  additionalTypeMappings: {
    CustomType: "CustomDartType",
    CustomCssVariables: "Map<String, String>",
  },
});

// Option 2: Create custom config from scratch
export const customDartConfig = createDartConversionConfig({
  templateRootPath: path.resolve("templates", "dart"),
  useJsonSerializable: true,
  additionalTypeMappings: {
    CustomType: "CustomDartType",
    CustomCssVariables: "Map<String, String>",
  },
});

// Export all configs
export const Configs = {
  dart: dartConfig,
  customDart: customDartConfig,
  // Add other language configs here
};
  1. Use the exported config in your code:
import { TypeScriptConverter } from "@thoughtspot/ts-to-any";
import { Configs } from "./config";

// Using extended default config
const converter1 = new TypeScriptConverter({
  conversionConfig: Configs.dart,
  inputConfig: {
    inputFiles: ["src/types.ts"],
  },
});

// Using custom config
const converter2 = new TypeScriptConverter({
  conversionConfig: Configs.customDart,
  inputConfig: {
    inputFiles: ["src/types.ts"],
  },
});

Configuration Options

Dart Configuration

The createDartConversionConfig function accepts the following options:

type DartConfig = {
  // Path to custom templates (optional)
  templateRootPath?: string;

  // Custom template content (optional)
  templateContent?: Partial<TemplateContent>;

  // Additional type mappings (optional)
  additionalTypeMappings?: Record<string, string>;

  // Enable JSON serialization support (optional)
  useJsonSerializable?: boolean;
};

Default Type Mappings

The converter includes default type mappings for Dart:

{
    "string": "String",
    "number": "int",
    "boolean": "bool",
    "array": "List",
    "object": "Map",
    "function": "Function",
    "any": "dynamic",
    "void": "void",
    "null": "Null",
    "undefined": "Null",
    "true": "bool",
    "false": "bool",
    "Promise": "Future<dynamic>"
}

Custom Type Mappings

You can add custom type mappings to the configuration:

const converter = new TypeScriptConverter({
  conversionConfig: createDartConversionConfig({
    additionalTypeMappings: {
      CustomType: "CustomDartType",
      CustomCssVariables: "Map<String, String>",
    },
  }),
  inputConfig: {
    inputFiles: ["src/types.ts"],
  },
});

Custom Templates

You can provide custom templates by specifying a template root path:

const converter = new TypeScriptConverter({
  conversionConfig: createDartConversionConfig({
    templateRootPath: "./custom-templates/dart",
  }),
  inputConfig: {
    inputFiles: ["src/types.ts"],
  },
});

Features

  • Convert TypeScript types to Dart
  • Support for JSON serialization
  • Custom type mappings
  • Custom templates
  • Configurable logging
  • Multiple input file support

Requirements

  • Node.js
  • TypeScript
  • Required dependencies:
    • @thoughtspot/ts-to-any
    • path (for path resolution)

License

[Add your license information here]