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

[engsys] upgrade dev dependency typescript #17776

Closed
KarishmaGhiya opened this issue Sep 22, 2021 · 4 comments
Closed

[engsys] upgrade dev dependency typescript #17776

KarishmaGhiya opened this issue Sep 22, 2021 · 4 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. EngSys This issue is impacting the engineering system.

Comments

@KarishmaGhiya
Copy link
Member

KarishmaGhiya commented Sep 22, 2021

Move to TypeScript 4.4

Major breaking issue: TypeScript 4.4 introduces a new flag called --useUnknownInCatchVariables. This flag changes the default type of catch clause variables from any to unknown.

we could use this flag to opt in as we are fixing libraries gradually.

This issue tracks the work to upgrade to 4.4 and use the flag to disable the check in the shared tsconfig.

Fix option 1:

try {
    executeSomeThirdPartyCode();
}
catch (err) { // err: unknown

    // Error! Property 'message' does not exist on type 'unknown'.
    console.error(err.message);

    // Works! We can narrow 'err' from 'unknown' to 'Error'.
    if (err instanceof Error) {
        console.error(err.message);
    }
}

Fix option 2:

try {
    executeSomeThirdPartyCode();
}
catch (err: any) {
    console.error(err.message); // Works again!
}

Personally I prefer option 1 over option 2 because option 2 just get rid of the compilation error but doesn't get any benefits from enabling the option..

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 22, 2021
@KarishmaGhiya KarishmaGhiya added the Client This issue points to a problem in the data-plane of the library. label Sep 22, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 22, 2021
@KarishmaGhiya KarishmaGhiya added EngSys This issue is impacting the engineering system. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Sep 22, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 22, 2021
@jeremymeng jeremymeng changed the title [engsys] upgrade dependency typescript [engsys] upgrade dev dependency typescript Sep 23, 2021
@deyaaeldeen
Copy link
Member

I played with this a little bit and found that we will need to upgrade the api extractor first to v7.18.11 to play well with typescript@4.4. Otherwise, v7.7.11 will throw Error: Error parsing tsconfig.json content: Unknown compiler option 'useUnknownInCatchVariables'. This upgrade will update the api views for all packages so we will need to do it gradually. /cc @maorleger since he was interested in upgrading the api extractor before.

@maorleger
Copy link
Member

Thank you @deyaaeldeen for the heads up! It does sound like upgrading API Extractor is something we are bumping into a few times already. I spoke to @xirzec and @ramya-rao-a and we should just rip the band-aid out and do the upgrade. I'll take #9410 and will likely complete it early October - hopefully that works with your schedule?

@deyaaeldeen
Copy link
Member

@maorleger thanks a lot for doing this! That definitely works!

@jeremymeng
Copy link
Member

Most packages have been moved to v4.6. Codegen is also updated to use v4.6 in generated code. There are some track1 packages that remain untouched. We will keep them that way.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. EngSys This issue is impacting the engineering system.
Projects
None yet
4 participants