Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class AdminLogEntity {
public username?: string;
}

interface AdminLogSaveParams {
username?: string,
}

async function main() {
await mongoose.connect(`mongodb://localhost:27017/`, {
dbName: 'verifyMASTER',
Expand All @@ -19,11 +23,26 @@ async function main() {
const adminLogModel: ReturnModelType<typeof AdminLogEntity, BeAnObject> = getModelForClass(AdminLogEntity);
const options: mongoose.CreateOptions = { session };

const adminLogEntity = await adminLogModel.create({}, options);
const params = {
username: 'a',
}

const params2: AdminLogSaveParams = {
username: 'b',
}

// This does not work
const adminLogEntity = await adminLogModel.create(params, options);
// But the next 2 lines work
const adminLogEntity2 = await adminLogModel.create(params2, options);
const adminLogEntity3 = await adminLogModel.create({ username: 'a' }, options);

console.log('entity', adminLogEntity);
console.log('entity2', adminLogEntity2);
console.log('entity3', adminLogEntity3);

await mongoose.disconnect();
}

main();

53 changes: 25 additions & 28 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
{
"compileOnSave": true,
"typeAcquisition": {
"enable": true
},
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declarationMap": true,
"outDir": "lib",
"moduleResolution": "node",
"target": "ES2021",
"module": "commonjs",
"newLine": "LF",
"sourceMap": true,
"removeComments": true,
"strict": true,
"allowUnreachableCode": false,
"pretty": true,
"declaration": true,
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo",
"lib": [
"esnext"
]
},
"include": [
"src/**/*"
]
"compileOnSave": true,
"typeAcquisition": {
"enable": true
},
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declarationMap": true,
"outDir": "lib",
"moduleResolution": "node",
"target": "ES2021",
"module": "commonjs",
"newLine": "LF",
"sourceMap": true,
"removeComments": true,
"strict": true,
"strictPropertyInitialization": false,
"allowUnreachableCode": false,
"pretty": true,
"declaration": true,
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo",
"lib": ["esnext"]
},
"include": ["src/**/*"]
}