| |
| |
| |
| |
| @@ -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); |
| +} |
| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,3 @@ |
| +{ |
| + "test_commands": ["npx tsd"] |
| +} |
| |
| new file mode 100755 |
| |
| |
| @@ -0,0 +1,8 @@ |
| +#!/usr/bin/env bash |
| + |
| +set -uo pipefail |
| +cd /testbed |
| +rc=0 |
| +npx tsd |
| +rc=$(( rc | $? )) |
| +exit $rc |
|
|