Skip to content

Transpile into Babel/tcomb syntax #5125

@jednano

Description

@jednano

I know this is a stretch, but what if you could set a flag to transpile TS code into code that would be readable by babel-plugin-tcomb, which came out recently? This would enable runtime type checking, which I previously brought up in #1573, but it would require interfaces be transpiled into structs:

interface Point {
    x: number;
    y: number;
}

function foo(point: Point) {
    return point.x * point.y;
}

becomes...

import t from 'tcomb';

const Point = t.struct({
    x: t.Number,
    y: t.Number
});

function foo(point: Point) {
    return point.x * point.y;
}

If not provided directly by the compiler, the same could be achieved by a 3rd party module, if only a concrete syntax tree #625 were provided.

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionOut of ScopeThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions