-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix: allow to push single items in arrays #182
Conversation
Can you add some tests? |
I added some tests, let me know your thoughts on them 😄 Also, I noticed that some tests that should fail, don't really fail, for example: // literal.test-d.ts
expectAssignable<Model>({
id: 0,
simple: 1,
optional: 2,
list: [3]
}); // ✅ it passes correctly
// copy the above code and replace the method with 'expectNotAssignable'
expectNotAssignable<Model>({
id: 0,
simple: 1,
optional: 2,
list: [3]
}); // ❌ the test passes but it should fail because this can be assigned to Model My understanding is that this happens because of how arrays are handled in the |
Should I wait for this fix at tsd? |
I don't think it would make much of a difference waiting for the tsd fix/suggestion on how to handle arrays since that currently affects new and old tests. I can open a new issue to improve the tests depending on what the fix is for that issue |
@Yarmeli ok. CI is still failing |
Can you run |
Hopefully, this should have worked 🤞 I am having issues on my local machine with prettier not being able to find prettier plugin modules for this repo 😞 |
@Yarmeli Just a quick note. Might be you saw already, last week I released TSTyche, a fresh type testing tool. This is the one I promised in tsdjs/tsd#199 Repo: https://github.com/tstyche/tstyche Before we talked about widening of inferred types. I explained it in documentation. This is how TypeScript works and that is for good reason. But with TSTyche you can avoid widening in your type tests by comparing two types: import { expect } from "tstyche";
interface Options {
locale?: Array<"en" | "de">;
root?: string;
}
expect<Options>().type.toBeAssignable<{
locale: ["en", "de"];
}>();
expect<Options>().type.toBeAssignable<{
root: string;
}>(); Also with TSTyche you can test types on specific versions of TypeScript: PS Commenting here, because I don’t feel like this is anyhow related with |
Implemented a fix for #181