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

Rename a field in two test exceptions. #2

Conversation

markdoliner-doma
Copy link

I'm merging a small change that I made in our mdoliner-st/Add_a_StructLike_class_that_extends_Error branch into our all_states_title_changes branch.


When using the new version of thrift-typescript where exceptions derive from Error, it's problematic to shadow Error's message field. In this case the problem is that our message was optional and Error's message is required, but I think it's good practice to avoid reusing message altogether.

Before this change the prettier --write 'src/**/*.ts' command was showing this error:

src/tests/generated/common/AuthException.ts:81:12 - error TS2416: Property 'message' in type 'AuthException' is not assignable to the same property in base type 'ErrorStructLike'.
  Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.

81     public message?: string;
              ~~~~~~~

src/tests/generated/exceptions/InvalidResult.ts:81:12 - error TS2416: Property 'message' in type 'InvalidResult' is not assignable to the same property in base type 'ErrorStructLike'.
  Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.

81     public message?: string;
              ~~~~~~~

Found 4 errors.

When using the new version of thrift-typescript where exceptions derive from `Error`, it's problematic to shadow `Error`'s `message` field. In this case the problem is that our message was optional and `Error`'s message is required, but I think it's good practice to avoid reusing `message` altogether.

Before this change the `prettier --write 'src/**/*.ts'` command was showing this error:
```
src/tests/generated/common/AuthException.ts:81:12 - error TS2416: Property 'message' in type 'AuthException' is not assignable to the same property in base type 'ErrorStructLike'.
  Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.

81     public message?: string;
              ~~~~~~~

src/tests/generated/exceptions/InvalidResult.ts:81:12 - error TS2416: Property 'message' in type 'InvalidResult' is not assignable to the same property in base type 'ErrorStructLike'.
  Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.

81     public message?: string;
              ~~~~~~~

Found 4 errors.
```
@markdoliner-doma markdoliner-doma merged commit 169368e into all_states_title_changes Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant