Skip to content

chore: Add generics to typescript generator #4664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix darwin unit test
  • Loading branch information
Emyrk committed Oct 20, 2022
commit 0f07e2815d5fb4dac00067c01964cd9e38e24aa9
4 changes: 3 additions & 1 deletion scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"go/types"
"os"
"path"
"path/filepath"
"reflect"
"regexp"
Expand Down Expand Up @@ -340,7 +341,8 @@ func (g *Generator) generateOne(m *Maps, obj types.Object) error {

func (g *Generator) posLine(obj types.Object) string {
file := g.pkg.Fset.File(obj.Pos())
return fmt.Sprintf("// From %s\n", filepath.Join("codersdk", filepath.Base(file.Name())))
// Do not use filepath, as that changes behavior based on OS
return fmt.Sprintf("// From %s\n", path.Join("codersdk", filepath.Base(file.Name())))
}

// buildStruct just prints the typescript def for a type.
Expand Down
6 changes: 2 additions & 4 deletions scripts/apitypings/main_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//go:build !windows && !darwin
// +build !windows,!darwin
//go:build !windows
// +build !windows

// Windows tests fail because the \n\r vs \n. It's not worth trying
// to replace newlines for os tests. If people start using this tool on windows
// and are seeing problems, then we can add build tags and figure it out.

// Darwin builds fail because of the "/" direction.
package main

import (
Expand Down