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

Implement json2typescript 1.5.0-rc.0 #360

Open
andreas-aeschlimann opened this issue Jul 26, 2021 · 5 comments
Open

Implement json2typescript 1.5.0-rc.0 #360

andreas-aeschlimann opened this issue Jul 26, 2021 · 5 comments
Assignees
Labels
dependencies Pull requests that update a dependency file

Comments

@andreas-aeschlimann
Copy link
Contributor

I would like to inform you about the newest update of json2typescript. It is currently in RC state.

There are no breaking changes, but some deprecations and property name changes. Everything should still work as expected.

@andreas-aeschlimann
Copy link
Contributor Author

Does it work for you, @kilchenmann?

@kilchenmann
Copy link
Contributor

@andreas-aeschlimann Thank you for the information. I'm sorry, I didn't saw your first comment and we haven't updated json2typescript yet.

@kilchenmann
Copy link
Contributor

kilchenmann commented Sep 9, 2021

I updated now json2typescript to the mentioned version (s. #371).

First I had to update some imports (e.g. PropertyMatchingRule) but it's fine.
Then I had other minor issues which were also easy to fix. But now I'm struggling with the following when running the unit tests. I tried several thing but it's getting even worse 🙈

09 09 2021 05:11:53.738:ERROR [compiler.karma-typescript]: src/models/api-response-data.ts(79,17): error TS2322: Type 'object' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'object'.

09 09 2021 05:11:53.740:ERROR [compiler.karma-typescript]: src/models/api-response-data.ts(79,90): error TS2345: Argument of type 'new () => T' is not assignable to parameter of type 'new () => object'.
  Type 'T' is not assignable to type 'object'.

@kilchenmann kilchenmann self-assigned this Sep 9, 2021
@kilchenmann kilchenmann added the dependencies Pull requests that update a dependency file label Sep 9, 2021
@andreas-aeschlimann
Copy link
Contributor Author

I updated now json2typescript to the mentioned version (s. #371).

First I had to update some imports (e.g. PropertyMatchingRule) but it's fine.
Then I had other minor issues which were also easy to fix. But now I'm struggling with the following when running the unit tests. I tried several thing but it's getting even worse 🙈

09 09 2021 05:11:53.738:ERROR [compiler.karma-typescript]: src/models/api-response-data.ts(79,17): error TS2322: Type 'object' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'object'.

09 09 2021 05:11:53.740:ERROR [compiler.karma-typescript]: src/models/api-response-data.ts(79,90): error TS2345: Argument of type 'new () => T' is not assignable to parameter of type 'new () => object'.
  Type 'T' is not assignable to type 'object'.

It looks like some types were a bit inaccurate in the original code. There is no breaking change, but some types are checked more consistently so this can happen.

I think the problem is that ajaxResponse.response is of type object instead of type any. I would try to write

responseData.body = jsonConvert.deserializeObject(ajaxResponse.response as any, dataType);.

Does that help? If not, which operation causes the error?

@kilchenmann
Copy link
Contributor

It looks like some types were a bit inaccurate in the original code.

Yes, this is also what I thought.

No worries. Go ahead and release the new version of json2typescript. I will have a look at the update on our side later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants