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
TypeScript: conditional default type error #11828
Comments
I cant reproduce this bug
Actually the typing for default is pretty wide. Note: changed "can" to "can't" |
@Uzlopak I'm confused. Can you or can you not reproduce it? |
sry, I meant I can not reproduce. |
@AbdelrahmanHafez @IslandRhythms can you reproduce it? |
I can reproduce the issue in one of the projects that I use TS on. |
I took a look, I have a fix but I have not the slightest idea why this issue happens or why my fix works. The issue is that the below TS: const t: SchemaTypeOptions<boolean> = {
type: Boolean,
default() {
return this.name === 'Hafez';
}
}; gets the below error:
Why TypeScript thinks the function type is |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
No type errors
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 16.3.1
Mongoose: 6.3.4
MongoDB: 5.0.5
The text was updated successfully, but these errors were encountered: