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

Replace as with satisfies keyword #19856

Closed
RahulGautamSingh opened this issue Jan 16, 2023 · 6 comments · Fixed by #22442
Closed

Replace as with satisfies keyword #19856

RahulGautamSingh opened this issue Jan 16, 2023 · 6 comments · Fixed by #22442
Assignees
Labels
priority-4-low Low priority, unlikely to be done unless it becomes important to more people status:in-progress Someone is working on implementation type:refactor Refactoring or improving of existing code

Comments

@RahulGautamSingh
Copy link
Collaborator

RahulGautamSingh commented Jan 16, 2023

Describe the proposed change(s).

Typescript recently got a new keyword satisfies. In a recent discussion on the Slack channel it was agreed upon to replace as with satisfies

There some detailed info this issue.

I am not sure if all instances of as need to be repalced. If they can be good, else I will list the reasons as I find them and
this issue will be used to track all related updates/changes on that topic.

@RahulGautamSingh RahulGautamSingh added type:refactor Refactoring or improving of existing code status:requirements Full requirements are not yet known, so implementation should not be started priority-5-triage labels Jan 16, 2023
@viceice viceice added status:in-progress Someone is working on implementation priority-4-low Low priority, unlikely to be done unless it becomes important to more people and removed status:requirements Full requirements are not yet known, so implementation should not be started priority-5-triage labels Jan 16, 2023
@RahulGautamSingh
Copy link
Collaborator Author

RahulGautamSingh commented Jan 31, 2023

git.getRepoStatus.mockResolvedValueOnce({
modified: [] as string[],
} as StatusResult);

There are many tests where such assertions are used. I don't think we can use satisfies here. Will it be desirable to instead initialize a minimal mockObject that has all non-optional properties and use that instead:

const mockStatusResult: StatusResult = { ...haveAllStrictFields }

..

git.getRepoStatus.mockResolvedValueOnce(mockStatusResult);
git.getRepoStatus.mockResolvedValueOnce({ ...mockStatusResult, modified:['somefile']});

@viceice
Copy link
Member

viceice commented Feb 2, 2023

we should probably use our partial helper function there.

@HonkingGoose
Copy link
Collaborator

Do we need to update our developer best practice documentation 1 to tell contributors/maintainers to use satisfies instead of as keyword?

Footnotes

  1. https://github.com/renovatebot/renovate/blob/main/docs/development/best-practices.md

@viceice
Copy link
Member

viceice commented Feb 22, 2023

yes please

@rarkins
Copy link
Collaborator

rarkins commented May 23, 2023

@RahulGautamSingh much work left here?

@RahulGautamSingh
Copy link
Collaborator Author

There are still some test files where we use any / never . Maybe 2 more PRs are needed.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority-4-low Low priority, unlikely to be done unless it becomes important to more people status:in-progress Someone is working on implementation type:refactor Refactoring or improving of existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants