Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs-src/blog/2026-04-28-more-programming-language-exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ draft: true

We've expanded export options for programming-language-style output so it is easier to move table data into application code.

This release builds on the existing JavaScript export and adds both Python and Java export support with configurable output options.
This release builds on the existing JavaScript export and adds Python, Java, and TypeScript export support with configurable output options.

<!--truncate-->

Expand Down Expand Up @@ -39,6 +39,15 @@ Read the docs:
- [Java Data Format](/docs/data-formats/java/java)
- [Java Options](/docs/data-formats/java/options)

## TypeScript

TypeScript export supports both anonymous-object and class-instance output and includes options for collection type (`Array<T>` or `T[]`), variable assignment, number conversion, and pretty printing with custom delimiters.

Read the docs:

- [TypeScript Data Format](/docs/data-formats/typescript/typescript)
- [TypeScript Options](/docs/data-formats/typescript/options)

## JavaScript

JavaScript export continues to support object-array output with configurable formatting and conversion options.
Expand Down
55 changes: 55 additions & 0 deletions docs-src/docs/030-data-formats/typescript/010-typescript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
sidebar_position: 1
title: "TypeScript"
description: "TypeScript is a typed superset of JavaScript and can represent tabular data as typed arrays of objects or class instances. You can export grid data as TypeScript-ready source in AnyWayData.com."
---

TypeScript is a strongly typed programming language and the AnyWayData TypeScript option is useful when you need typed, copy/paste-ready data for tests, fixtures, demos, and prototypes.

## What is TypeScript Data Output?

TypeScript can represent table-like data using arrays of anonymous objects or arrays of class instances.

For example, a typed array of anonymous objects:

```ts
const data: Array<Record<string, unknown>> = [
{"user": "Jesse.Bradtke97", "name": "Corine"},
{"user": "Cielo.Little", "name": "Zander"}
];
```

In the example above:

- each row is represented as an object literal using key/value pairs
- object keys come from the column headers
- row objects are collected in a typed TypeScript array

AnyWayData can also generate class-instance output where each row is represented as an instance of a named TypeScript class.

## How is TypeScript Output different from JSON and Javascript?

JSON is a language-independent data format and JavaScript object arrays are JavaScript syntax.

TypeScript output uses TypeScript syntax and typing concepts:

- rows can be emitted as anonymous object literals or named class instances
- output can be generated as `Array<T>` or `T[]`
- values can be emitted as quoted strings or numeric literals
- output can be assigned to a named, typed variable

Unlike JSON, TypeScript output is designed to be used directly in TypeScript code.

## AnyWayData Support for TypeScript

AnyWayData currently supports **exporting** data to TypeScript format.

You can configure output options such as:

- collection type (`Array<T>` or `T[]`)
- variable assignment and naming
- number conversion (quoted vs unquoted)
- anonymous-object vs class-instance output
- pretty print indentation and custom delimiter

TypeScript output can be generated from the same grid data used for the other supported export formats.
85 changes: 85 additions & 0 deletions docs-src/docs/030-data-formats/typescript/options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
sidebar_position: 2
title: "TypeScript Options"
description: "Options available for converting to TypeScript in AnyWayData.com. This includes collection and object style, variable assignment, number conversion, and pretty print formatting."
---

The configuration options for TypeScript are listed below.

## Collection Type

Choose whether the outer container is generated as:

- `List (Array<T>)`
- `Array [ ]`

In generated output this maps to `Array<T>` or `T[]` type annotations.

## Assign to Variable

When enabled, output is assigned to a typed variable.

For example:

```ts
const data: Array<Record<string, unknown>> = [
{"name": "Monica"}
];
```

## Variable Name

Set the name used when `Assign to Variable` is enabled.

For example, using `records`:

```ts
const records: Array<Record<string, unknown>> = [
{"name": "Monica"}
];
```

## Number Convert (Quote Numbers)

When enabled, numeric-looking values are emitted as quoted strings.

When disabled, numeric-looking values are emitted as numeric literals.

## Use Anonymous Objects

When enabled, each row is output as an anonymous object literal.

When disabled, each row is output as an instance of a named TypeScript class.

## Class Name

Used when `Use Anonymous Objects` is disabled to set the class name for generated row instances.

## Blank Values

Choose how blank values are exported:

- `null`
- `Empty String`

## Pretty Print

Controls whether output is formatted across multiple lines with indentation.

When disabled, output is compact (minified style).

## Delimiter

Controls indentation when `Pretty Print` is enabled.

TypeScript supports:

- `Tab [\t]`
- `Space [ ]`
- `Custom Value`

## Custom Delimiter

Set a custom indentation value used for pretty print.

For TypeScript output, indentation must be whitespace. Non-whitespace values automatically fall back to safe spaces.
1 change: 1 addition & 0 deletions js/data_formats/file-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fileTypes['json'] = { type: 'json', fileExtension: '.json' };
fileTypes['javascript'] = { type: 'javascript', fileExtension: '.js' };
fileTypes['python'] = { type: 'python', fileExtension: '.py' };
fileTypes['java'] = { type: 'java', fileExtension: '.java' };
fileTypes['typescript'] = { type: 'typescript', fileExtension: '.ts' };
fileTypes['gherkin'] = { type: 'gherkin', fileExtension: '.gherkin' };
fileTypes['html'] = { type: 'html', fileExtension: '.html' };
fileTypes['asciitable'] = { type: 'asciitable', fileExtension: '.txt' };
Expand Down
Loading
Loading