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

TypeScript: support "useUnknownInCatchVariables" compiler option #145

Open
bitc opened this issue Oct 7, 2021 · 5 comments
Open

TypeScript: support "useUnknownInCatchVariables" compiler option #145

bitc opened this issue Oct 7, 2021 · 5 comments

Comments

@bitc
Copy link

bitc commented Oct 7, 2021

Hi, it would be nice if the generated TypeScript code would be compatible with https://www.typescriptlang.org/tsconfig#useUnknownInCatchVariables

The fix is make sure that all "catch" blocks have an : unknown type annotation.

Thank you

@timbod7
Copy link
Collaborator

timbod7 commented Oct 9, 2021

Would this generated code work in older versions of typescript? Having had problems with this in the past, we test that the generate code works with typescript versions 2.9, 3.5 and 3.8 and deno 1.10. See:

https://github.com/timbod7/adl/tree/master/typescript/tests

@bitc
Copy link
Author

bitc commented Oct 9, 2021

I see, looks nice. I think it should be able to work also in older versions of TypeScript.

A quick-fix is to add @ts-ignore before every catch statement. But a cleaner solution should also be possible

@timbod7
Copy link
Collaborator

timbod7 commented Jan 18, 2022

FWIW, we normally turn off linting for all the generated code - there doesn't seem to be much value in lint checking code that wasn't written by humans.

@bitc
Copy link
Author

bitc commented Jan 19, 2022

That makes sense. I guess it comes down to how you organize your project.

Here is how I do things: I copy all of the adl generated TypeScript files directly into my project, and compile them all together along with my application code, using a single "tsconfig.json" file. This seems like the simplest way to do things, but then there is a problem if the settings I want in my "tsconfig.json" file are not compatible with the generated code.

An alternate approach would be to use a separate "tsconfig.json" file for the adl generated TypeScript code, but this makes the project setup more complex.

@paul-thompson-helix
Copy link
Collaborator

Addressed by #155

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