gzuidhof / tygo

Generate Typescript types from Golang source code
MIT License
572 stars 39 forks source link

`TypeMappings` usage #55

Closed perkrlsn closed 1 month ago

perkrlsn commented 2 months ago

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.

gzuidhof commented 2 months ago

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.