Closed Anonymous4078 closed 7 months ago
Needs a fix
@Anonymous4078 what does your schema look like?
@vkarpov15 Simple schema which break is :
import { Schema, model } from 'mongoose';
interface GuildConfig {
guildId: string;
channelIds: string[];
}
const schema = new Schema<GuildConfig>({
guildId: String,
channelIds: [String],
});
export const collection = model<GuildConfig>('cooldowns', schema);
Worked perfectly fine till version 8.2.2 and breaks in v8.2.3
I'm unable to repro, the following script compiles fine:
import { Schema, model } from 'mongoose';
interface GuildConfig {
guildId: string;
channelIds: string[];
}
const schema = new Schema<GuildConfig>({
guildId: String,
channelIds: [String],
});
const collection = model<GuildConfig>('cooldowns', schema);
const guildId = '42';
collection.findOneAndUpdate(
{ guildId },
{
$pull: { channelIds: 'test' },
},
);
output:
$ ./node_modules/.bin/tsc --strict gh-14462.ts
$
$ head ./node_modules/typescript/package.json
{
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "https://www.typescriptlang.org/",
"version": "5.4.3",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
"TypeScript",
"Microsoft",
$ head ./node_modules/mongoose/package.json
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "8.3.0",
"author": "Guillermo Rauch <guillermo@learnboost.com>",
"keywords": [
"mongodb",
"document",
"model",
"schema",
$
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
This issue was closed because it has been inactive for 19 days and has been marked as stale.
Not fixed
For my case it is resolved.
mongoose@8.3.2
resolved the generics typing issues that I was seeing starting with 8.2.3, but 8.3.3 has reintroduced similar TS2322 errors in our TypeGoose project.
@KeithGillette please open a new issue and follow the issue template
Prerequisites
Mongoose version
8.2.3
Node.js version
20.11.1
MongoDB server version
5.x
Typescript version (if applicable)
5.4.3
Description
My code used to work till v8.2.2 and types suddenly broke with 8.2.3
Steps to Reproduce
Expected Behavior
The types shouldn't break in a semver patch change