File size: 2,039 Bytes
29fc4be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts
index fc0204e2a..fc7ae0fa0 100644
--- a/test/types/schema.test.ts
+++ b/test/types/schema.test.ts
@@ -1230,3 +1230,51 @@ async function gh13797() {
expectType<IUser>(this); return '';
} } });
}
+
+function gh13900StringMapOfNumber() {
+ const schema = new Schema({
+ myMap: { type: 'Map', of: Number, required: true }
+ });
+ const Test = model('Test_gh13900_num', schema);
+
+ const doc = new Test({ myMap: { answer: 42 } });
+ expectType<Map<string, number>>(doc.myMap);
+ expectType<number | undefined>(doc.myMap!.get('answer'));
+}
+
+function gh13900StringMapOfString() {
+ const schema = new Schema({
+ myMap: { type: 'Map', of: String, required: true }
+ });
+ const Test = model('Test_gh13900_str', schema);
+
+ const doc = new Test({ myMap: { answer: 'hi' } });
+ expectType<Map<string, string>>(doc.myMap);
+ expectType<string | undefined>(doc.myMap!.get('answer'));
+}
+
+function gh13900StringMapOfMixed() {
+
+ const schema = new Schema({
+ instance: {
+ type: 'Map',
+ of: Schema.Types.Mixed,
+ required: true
+ }
+ });
+ const Test = model('Test_gh13900_mixed', schema);
+
+ const doc = new Test({ instance: { foo: 1 } });
+ expectType<Map<string, any>>(doc.instance);
+}
+
+function gh13900StringMapPreservesConstructorBehavior() {
+
+ const schema = new Schema({
+ myMap: { type: Map, of: Number, required: true }
+ });
+ const Test = model('Test_gh13900_ctor', schema);
+
+ const doc = new Test({ myMap: { x: 1 } });
+ expectType<Map<string, number>>(doc.myMap);
+}
diff --git a/test_commands.json b/test_commands.json
new file mode 100644
index 000000000..0f7dbefd0
--- /dev/null
+++ b/test_commands.json
@@ -0,0 +1,3 @@
+{
+ "test_commands": ["npx tsd"]
+}
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
new file mode 100755
--- /dev/null
+++ b/mimo_test_command.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+set -uo pipefail
+cd /testbed
+rc=0
+npx tsd
+rc=$(( rc | $? ))
+exit $rc
|