mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
POST license API endpoint (#3570)
* POST license API Signed-off-by: Spike Curtis <spike@coder.com> * Support interface{} types in generated Typescript Signed-off-by: Spike Curtis <spike@coder.com> * Disable linting on empty interface any Signed-off-by: Spike Curtis <spike@coder.com> * Code review updates Signed-off-by: Spike Curtis <spike@coder.com> * Enforce unique licenses Signed-off-by: Spike Curtis <spike@coder.com> * Renames from code review Signed-off-by: Spike Curtis <spike@coder.com> * Code review renames and comments Signed-off-by: Spike Curtis <spike@coder.com> Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
@@ -382,8 +382,14 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
|
||||
return TypescriptType{}, xerrors.Errorf("map key: %w", err)
|
||||
}
|
||||
|
||||
aboveTypeLine := keyType.AboveTypeLine
|
||||
if aboveTypeLine != "" && valueType.AboveTypeLine != "" {
|
||||
aboveTypeLine = aboveTypeLine + "\n"
|
||||
}
|
||||
aboveTypeLine = aboveTypeLine + valueType.AboveTypeLine
|
||||
return TypescriptType{
|
||||
ValueType: fmt.Sprintf("Record<%s, %s>", keyType.ValueType, valueType.ValueType),
|
||||
ValueType: fmt.Sprintf("Record<%s, %s>", keyType.ValueType, valueType.ValueType),
|
||||
AboveTypeLine: aboveTypeLine,
|
||||
}, nil
|
||||
case *types.Slice, *types.Array:
|
||||
// Slice/Arrays are pretty much the same.
|
||||
@@ -458,6 +464,14 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
|
||||
}
|
||||
resp.Optional = true
|
||||
return resp, nil
|
||||
case *types.Interface:
|
||||
// only handle the empty interface for now
|
||||
intf := ty
|
||||
if intf.Empty() {
|
||||
return TypescriptType{ValueType: "any",
|
||||
AboveTypeLine: indentedComment("eslint-disable-next-line")}, nil
|
||||
}
|
||||
return TypescriptType{}, xerrors.New("only empty interface types are supported")
|
||||
}
|
||||
|
||||
// These are all the other types we need to support.
|
||||
|
||||
Reference in New Issue
Block a user