Skip to content

Commit 7f06b35

Browse files
author
tru
committed
(1) upgrade typescript to 3.1.3
(2) typescript 2.9 not allow symbol to be used as index. microsoft/TypeScript#1863. Current there is a PR open to address this issue microsoft/TypeScript#26797
1 parent d4fe267 commit 7f06b35

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"chai": "^4.1.2",
3333
"mocha": "^3.5.3",
3434
"ts-node": "^6.0.3",
35-
"typescript": "2.8.3",
35+
"typescript": "3.1.3",
3636
"source-map-support": "^0.5.5"
3737
}
3838
}

src/CallsDontMatchError.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default class CallsDontMatchError extends Error {
1414

1515
constructor(expectedCall: ArgumentInvocation, otherInteractions: ArgumentInvocation[], methodName: PropertyKey) {
1616
super();
17-
let message = `${methodName} was not called with: ${expectedCall.prettyPrint()}\n`;
17+
18+
let message = `${String(methodName)} was not called with: ${expectedCall.prettyPrint()}\n`;
1819

1920
if (otherInteractions.length !== 0) {
2021
message = message + ` Other interactions with this mock: [${ prettyPrintOtherInteractions(otherInteractions)}]`;

src/StubbedActionMatcherRepo.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class StubbedActionMatcherRepo {
1010

1111
recordAndFindMatch(propertyKey: PropertyKey, argsToMatch: ArgumentInvocation): LookupResult {
1212
this.recordCall(propertyKey, argsToMatch);
13-
const stubbedActionMatchers = this.stubbedActionMatcherMap[propertyKey] || [];
13+
const stubbedActionMatchers = this.stubbedActionMatcherMap[String(propertyKey)] || [];
1414

1515
const [lastMatchedMatcher] =
1616
stubbedActionMatchers
@@ -36,31 +36,31 @@ export class StubbedActionMatcherRepo {
3636
}
3737

3838
private setStubbedActionMatcher(propertyKey: PropertyKey, stubbedActionMatcher: StubbedActionMatcher) {
39-
if (!this.stubbedActionMatcherMap[propertyKey])
40-
this.stubbedActionMatcherMap[propertyKey] = [];
39+
if (!this.stubbedActionMatcherMap[String(propertyKey)])
40+
this.stubbedActionMatcherMap[String(propertyKey)] = [];
4141

42-
this.stubbedActionMatcherMap[propertyKey].push(stubbedActionMatcher);
42+
this.stubbedActionMatcherMap[String(propertyKey)].push(stubbedActionMatcher);
4343
}
4444

4545
lookupCalls(propertyKey: PropertyKey): ArgumentInvocation[] {
46-
return this.callMap[propertyKey] || [];
46+
return this.callMap[String(propertyKey)] || [];
4747
}
4848

4949
private recordCall(propertyKey: PropertyKey, argsToMatch: ArgumentInvocation) {
50-
this.callMap[propertyKey] = (this.callMap[propertyKey] || []);
50+
this.callMap[String(propertyKey)] = (this.callMap[String(propertyKey)] || []);
5151

52-
this.callMap[propertyKey].push(argsToMatch)
52+
this.callMap[String(propertyKey)].push(argsToMatch)
5353
}
5454

5555
resetPropertyKey(propertyKey: PropertyKey) {
56-
this.stubbedActionMatcherMap[propertyKey] = [];
57-
this.callMap[propertyKey] = [];
56+
this.stubbedActionMatcherMap[String(propertyKey)] = [];
57+
this.callMap[String(propertyKey)] = [];
5858
}
5959

6060
private deleteCallRecord(propertyKey: PropertyKey, argumentInvocation: ArgumentInvocation) {
61-
this.callMap[propertyKey] = (this.callMap[propertyKey] || []);
61+
this.callMap[String(propertyKey)] = (this.callMap[String(propertyKey)] || []);
6262

63-
this.callMap[propertyKey] = this.callMap[propertyKey].filter((call) => !call.equivalentTo(argumentInvocation))
63+
this.callMap[String(propertyKey)] = this.callMap[String(propertyKey)].filter((call) => !call.equivalentTo(argumentInvocation))
6464

6565
}
6666
}

src/Verifier.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Verifier {
1919
const calls = this.repo.lookupCalls(this.propertyKey);
2020

2121
if (calls.length === 0)
22-
throw new Error(`${this.propertyKey} was never called`)
22+
throw new Error(`${String(this.propertyKey)} was never called`)
2323
}
2424

2525
//noinspection JSUnusedGlobalSymbols
@@ -49,7 +49,7 @@ class NeverVerifier {
4949
const calls = this.repo.lookupCalls(this.propertyKey);
5050

5151
if (calls.length !== 0)
52-
throw new Error(`${this.propertyKey} was called ${calls.length} times`)
52+
throw new Error(`${String(this.propertyKey)} was called ${calls.length} times`)
5353
}
5454

5555
//noinspection JSUnusedGlobalSymbols
@@ -62,7 +62,7 @@ class NeverVerifier {
6262
.filter(expectedCall => expectedArgumentInvocation.equivalentTo(expectedCall));
6363

6464
if (callsWithMatchingArgs.length !== 0) {
65-
throw new Error(`${this.propertyKey} was called ${callsWithMatchingArgs.length} times with ${expectedArgumentInvocation.prettyPrint()}`);
65+
throw new Error(`${String(this.propertyKey)} was called ${callsWithMatchingArgs.length} times with ${expectedArgumentInvocation.prettyPrint()}`);
6666
}
6767
}
6868

@@ -80,7 +80,7 @@ class TimesVerifier {
8080
const calls = this.repo.lookupCalls(this.propertyKey);
8181

8282
if (calls.length !== this.count)
83-
throw new Error(`${this.propertyKey} was was expected to be called ${this.count} times, but was called ${calls.length}`)
83+
throw new Error(`${String(this.propertyKey)} was was expected to be called ${this.count} times, but was called ${calls.length}`)
8484
}
8585

8686
//noinspection JSUnusedGlobalSymbols
@@ -93,7 +93,7 @@ class TimesVerifier {
9393
.filter(expectedCall => expectedArgumentInvocation.equivalentTo(expectedCall));
9494

9595
if (callsWithMatchingArgs.length !== this.count) {
96-
throw new Error(`${this.propertyKey} was called ${callsWithMatchingArgs.length} times with ${expectedArgumentInvocation.prettyPrint()} but was expected to be called ${this.count} times.`);
96+
throw new Error(`${String(this.propertyKey)} was called ${callsWithMatchingArgs.length} times with ${expectedArgumentInvocation.prettyPrint()} but was expected to be called ${this.count} times.`);
9797
}
9898
}
9999
}

0 commit comments

Comments
 (0)