Skip to content

chore: Add generics to typescript generator #4658

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

Closed
wants to merge 8 commits into from

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Oct 19, 2022

Golang

type Flaggable interface {
	string | bool | int | time.Duration | []string
}

type SomethingElse interface {
	time.Duration | bool
}

type DeploymentConfigField[T Flaggable, S SomethingElse] struct {
	Key        string
	Name       string
	Usage      string
	Flag       string
	Shorthand  string
	Enterprise bool
	Hidden     bool
	Value      T
	Else       S
}

Typescript

I think this is correct typescript

// From codersdk/deploymentconfig.go
export interface DeploymentConfigField<T extends Flaggable, S extends SomethingElse> {
  readonly Key: string
  readonly Name: string
  readonly Usage: string
  readonly Flag: string
  readonly Shorthand: string
  readonly Enterprise: boolean
  readonly Hidden: boolean
  readonly Value: T
  readonly Else: S
}

// From codersdk/deploymentconfig.go
export type Flaggable = string | boolean | number | string[]

// From codersdk/deploymentconfig.go
export type SomethingElse = number | boolean

@Emyrk Emyrk requested review from f0ssel and deansheather October 19, 2022 22:31
@github-actions
Copy link

github-actions bot commented Oct 19, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link
Member Author

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have read the CLA Document and I hereby sign the CLA

@Emyrk
Copy link
Member Author

Emyrk commented Oct 19, 2022

I have read the CLA Document and I hereby sign the CLA

@Emyrk
Copy link
Member Author

Emyrk commented Oct 20, 2022

Moved to main #4664

@Emyrk Emyrk closed this Oct 20, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2022
@Emyrk Emyrk deleted the stevenmasley/api_gen_generics branch February 3, 2023 19:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants