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

[archive] Fix usage with TypeScript 4.8+ #6779

Merged

Conversation

fcollonval
Copy link
Contributor

Pull Request

πŸ“– Description

Add typing to template variable to remove error seen in code consuming fast-foundation with TypeScript 4.8+

🎫 Issues

Fixes #6365

πŸ‘©β€πŸ’» Reviewer Notes

πŸ“‘ Test Plan

βœ… Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

I'm not sure how to test for this. I force locally a TypeScript update to 4.9.5 and fixed the error mentioned in @microsoft/fast-foundation.

There are also error in @microsoft/fast-router but this does not fix them.

Errors in @microsoft/fast-router
src/configuration.ts(49,9): error TS2322: Type 'DefaultRouteRecognizer' is not assignable to type 'RouteRecognizer'.
  The types returned by 'recognize(...)' are incompatible between these types.
    Type 'Promise | null>' is not assignable to type 'Promise | null>'.
      Type 'RecognizedRoute | null' is not assignable to type 'RecognizedRoute | null'.
        Type 'RecognizedRoute' is not assignable to type 'RecognizedRoute'.
          Type 'unknown' is not assignable to type 'TSettings'.
            'TSettings' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
src/recognizer.ts(271,17): error TS18047: 'segmentA' is possibly 'null'.
src/recognizer.ts(271,33): error TS18047: 'segmentB' is possibly 'null'.
src/recognizer.ts(275,17): error TS18047: 'segmentA' is possibly 'null'.
src/recognizer.ts(275,33): error TS18047: 'segmentB' is possibly 'null'.
src/router.ts(201,13): error TS2322: Type 'unknown' is not assignable to type 'Router | null | undefined'.

⏭ Next Steps

@chrisdholt
Copy link
Member

Thanks for this @fcollonval - do we have a repro of this I can check out? I recall us seeing a similar TS issue which disappeared with a different fix which wasn't specific to 4.8. If I can validate the issue, happy to take an update/fix assuming it makes sense.

@fcollonval
Copy link
Contributor Author

Thanks @chrisdholt

We have seen that first when working on https://github.com/brichet/jupyterlab/tree/toolbar_webcomponent (uses TypeScript 5.0.4).

But I bumped TypeScript (to 4.9.5) in the components library we are using built on fast v1 to ease error reproducibility: https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/actions/runs/5600572055/jobs/10243153138?pr=63#step:9:200

@chrisdholt
Copy link
Member

Thanks @chrisdholt

We have seen that first when working on https://github.com/brichet/jupyterlab/tree/toolbar_webcomponent (uses TypeScript 5.0.4).

But I bumped TypeScript (to 4.9.5) in the components library we are using built on fast v1 to ease error reproducibility: https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/actions/runs/5600572055/jobs/10243153138?pr=63#step:9:200

Thanks for this, sorry for the delay. I'm going to fork and pull your repo to try and reproduce this. I have a feeling it may not be the exact TS issue. I also could be wrong :)

@fcollonval
Copy link
Contributor Author

Thanks a lot for taking the time @chrisdholt

@m-akinc
Copy link
Contributor

m-akinc commented Aug 28, 2023

Any updates? Also interested in using TS 4.8+.

@@ -143,7 +143,7 @@ class DesignTokenImpl<T extends { createCSS?(): string }> extends CSSDirective
return [...this._appliedTo];
}

public static from<T>(
public static from<T extends { createCSS?(): string }>(
Copy link
Contributor

@atmgrifter00 atmgrifter00 Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be good to create a couple of local types to consolidate some of these type concerns. Namely:

type DesignTokenType = string | number | boolean | BigInteger | null | Array<any> | symbol | {};

type CSSDesignTokenType = DesignTokenType |
        ({
              createCSS?(): string;
         } & Record<PropertyKey, any>);

Then you could do something like this everywhere:

public static from<T extends CSSDesignTokenType> ...

I'll note that the changes here (with or without my proposed changes) do unblock our migration to Typescript 4.8, which is required for our components to work in the current version of Angular.

@rajsite
Copy link

rajsite commented Sep 25, 2023

The TypeScript version upgrade is blocking us from performing Angular upgrades without having all our applications disable library type checking.

Angular 14 support ends in November and we would like to be able to migrate to Angular 16 which requires TypeScript >=4.9.3.

Ideally we can avoid falling out of supported Angular version usage so hopefully within the next week or two we would like FAST to be compatible with a newer TypeScript version so we can bubble up support through our libraries. @chrisdholt do you think that would be possible?

@chrisdholt
Copy link
Member

The TypeScript version upgrade is blocking us from performing Angular upgrades without having all our applications disable library type checking.

Angular 14 support ends in November and we would like to be able to migrate to Angular 16 which requires TypeScript >=4.9.3.

Ideally we can avoid falling out of supported Angular version usage so hopefully within the next week or two we would like FAST to be compatible with a newer TypeScript version so we can bubble up support through our libraries. @chrisdholt do you think that would be possible?

We're focused on updating the latest alpha and beta versions, but it's requiring some changes to our testing libraries. The bulk of my effort for TS right now is going to focus on moving those versions forward towards stable and hopefully getting onto the latest TS version for alpha/beta versions so we can leverage TS's support for decorator metadata.

As it pertains to the archive branches - we can try to get some support there, but I would suggest starting to plan on how to move off those. Given the alpha/beta changes have been moving slower, we've continued to backport some fixes, but I don't see that going on forever. At some point, the code there is just difficult to maintain with backwards compatibility, especially given the amount of the time the FAST Components package has been deprecated. I'm keeping this open with the hopes we can get to updating the archive, but changes there are more difficult and time consuming as of now.

@chrisdholt
Copy link
Member

The TypeScript version upgrade is blocking us from performing Angular upgrades without having all our applications disable library type checking.
Angular 14 support ends in November and we would like to be able to migrate to Angular 16 which requires TypeScript >=4.9.3.
Ideally we can avoid falling out of supported Angular version usage so hopefully within the next week or two we would like FAST to be compatible with a newer TypeScript version so we can bubble up support through our libraries. @chrisdholt do you think that would be possible?

We're focused on updating the latest alpha and beta versions, but it's requiring some changes to our testing libraries. The bulk of my effort for TS right now is going to focus on moving those versions forward towards stable and hopefully getting onto the latest TS version for alpha/beta versions so we can leverage TS's support for decorator metadata.

As it pertains to the archive branches - we can try to get some support there, but I would suggest starting to plan on how to move off those. Given the alpha/beta changes have been moving slower, we've continued to backport some fixes, but I don't see that going on forever. At some point, the code there is just difficult to maintain with backwards compatibility, especially given the amount of the time the FAST Components package has been deprecated. I'm keeping this open with the hopes we can get to updating the archive, but changes there are more difficult and time consuming as of now.

Good news - I repro'd this locally when trying to update the repo. Let's see if @nicholasrice has any concerns with this; he may have ideas on where/why the constraint may be failing in this scenario as well.

@chrisdholt
Copy link
Member

chrisdholt commented Sep 28, 2023

Update on this - I got some insight from the TS team on why this is throwing now. I think we need to look at the best path forward and update this w/ TS.

@chrisdholt
Copy link
Member

Made it through getting the repo building with TS 4.8+, unfortunately it requires changing out all the test suites due to ESM requirements. Building this locally and if it passes I plan to push it through. Thanks @fcollonval for this PR and all for your patience.

@chrisdholt chrisdholt merged commit edf73f0 into microsoft:archives/fast-element-1 Sep 30, 2023
@fcollonval fcollonval deleted the fix/6365-typescript branch October 2, 2023 12:50
@fcollonval
Copy link
Contributor Author

Thanks @chrisdholt for taking the time of looking at this maintenance PR.

@rajsite
Copy link

rajsite commented Oct 2, 2023

Made it through getting the repo building with TS 4.8+, unfortunately it requires changing out all the test suites due to ESM requirements. Building this locally and if it passes I plan to push it through. Thanks @fcollonval for this PR and all for your patience.

That's awesome news, thanks @chrisdholt! Do you know when we might see the changes in a published package?

@rajsite
Copy link

rajsite commented Oct 11, 2023

Made it through getting the repo building with TS 4.8+, unfortunately it requires changing out all the test suites due to ESM requirements. Building this locally and if it passes I plan to push it through. Thanks @fcollonval for this PR and all for your patience.

That's awesome news, thanks @chrisdholt! Do you know when we might see the changes in a published package?

These changes are now in @microsoft/fast-foundation@2.49.2 πŸŽ‰

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

Successfully merging this pull request may close these issues.

5 participants