Skip to content
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

Should deprecated fields be optional? #993

Closed
husseinhere opened this issue Jan 29, 2024 · 3 comments
Closed

Should deprecated fields be optional? #993

husseinhere opened this issue Jan 29, 2024 · 3 comments

Comments

@husseinhere
Copy link

husseinhere commented Jan 29, 2024

Given the message:

message Amount {
  Currency currency = 1;
  int64    old_value = 2 [deprecated = true];
  double   value = 3;
}

ts-proto generates:

export interface Amount {
    currency: Currency;
    /** @deprecated */
    oldValue: number;
    value: number;
}

But wouldn't it be a lot nicer if oldValue was defined as oldValue?: number ?

@stephenh
Copy link
Owner

That seems reasonable; if you want to try adding that check here, we could see what happens:

https://github.com/stephenh/ts-proto/blob/main/src/types.ts#L356

stephenh pushed a commit that referenced this issue Mar 26, 2024
#1010)

Add `deprecatedOnly` option for `useOptionals` option to make only
deprecated fields optional. This PR aims to address the issue
#993
@tufandevrim
Copy link
Contributor

@husseinhere this issue/feature request should be addressed by #1010 now

@stephenh
Copy link
Owner

Closing this out thanks to #1010, thank you @tufandevrim !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants