gzuidhof / tygo

Generate Typescript types from Golang source code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`TypeMappings` usage

perkrlsn opened this issue · comments

Given the following simple example.

Input

packages:
  - path: "types/src/test"
    output_path: "src/types.ts"
    type_mappings:
      types.TestType: "number"
package types

type TestType string

Output

// Code generated by tygo. DO NOT EDIT.

//////////
// source: types.go

export type TestType = string;

Any help with the TypeMappings feature would be appreciated.

Does the following work?

    type_mappings:
     TestType: "number"

The main idea behind the type mappings is to allow for specifying types that are from a different package, not to override types.

If it doesn't work, what you could do is exclude the file that contains type TestType string, and rather use frontmatter to manually add the Typescript type you want to see.