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

Add @total-typescript/ts-reset for better standard library types #20553

Open
JamieMagee opened this issue Feb 21, 2023 · 3 comments
Open

Add @total-typescript/ts-reset for better standard library types #20553

JamieMagee opened this issue Feb 21, 2023 · 3 comments
Labels
priority-4-low Low priority, unlikely to be done unless it becomes important to more people type:refactor Refactoring or improving of existing code

Comments

@JamieMagee
Copy link
Contributor

JamieMagee commented Feb 21, 2023

Describe the proposed change(s).

@total-typescript/ts-reset improves some of the types in the standard library. For example:

  • Making JSON.parse return unknown instead of any
  • Making .filter(Boolean) filter out falsy values
  • Removing any[] from Array.isArray()

Discussed in slack

@JamieMagee JamieMagee 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 Feb 21, 2023
@HonkingGoose
Copy link
Collaborator

I see @rarkins and @viceice gave your idea a thumbs-up, so I'm labeling this status:ready so we can try it out and see what happens.

@HonkingGoose HonkingGoose added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:ready and removed priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started labels Mar 1, 2023
@JamieMagee JamieMagee self-assigned this Mar 9, 2023
@JamieMagee
Copy link
Contributor Author

clone is going to be a major pain to refactor

export function clone<T>(input: T | null = null): T {
const stringifiedInput = quickStringify(input);
return stringifiedInput ? JSON.parse(stringifiedInput) : null;
}

Currently its type signature is wrong. It should be T | null instead of just T, as there is an explicit null return there!

@viceice
Copy link
Member

viceice commented Mar 12, 2023

we should now use the node structuredClone function, as we're now on node v18

@rarkins rarkins added priority-4-low Low priority, unlikely to be done unless it becomes important to more people and removed priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others labels Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-4-low Low priority, unlikely to be done unless it becomes important to more people type:refactor Refactoring or improving of existing code
Projects
None yet
Development

No branches or pull requests

4 participants