Skip to content

Commit 415f943

Browse files
committed
Fix typing
Typescript thinks that errors could possible be undefined.
1 parent f56efba commit 415f943

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/slang/utils/__tests__/rttc.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test('Invalid unary type combinations return TypeError', () => {
3131
const context = mockRuntimeContext()
3232
const errors = operatorValue.map(opVals => {
3333
return rttc.checkUnaryExpression(context, opVals[0] as UnaryOperator, opVals[1])
34-
})
34+
}) as rttc.TypeError[]
3535
errors.map(error => expect(error).toBeInstanceOf(rttc.TypeError))
3636
errors.map(error => expect(error.explain()).toMatchSnapshot())
3737
errors.map(error => expect(error.elaborate()).toMatchSnapshot())
@@ -66,7 +66,7 @@ test('Invalid binary type combinations for + return TypeError', () => {
6666
const context = mockRuntimeContext()
6767
const errors = operatorValues.map(opVals => {
6868
return rttc.checkBinaryExpression(context, opVals[0] as BinaryOperator, opVals[1], opVals[2])
69-
})
69+
}) as rttc.TypeError[]
7070
errors.map(error => expect(error).toBeInstanceOf(rttc.TypeError))
7171
errors.map(error => expect(error.explain()).toMatchSnapshot())
7272
errors.map(error => expect(error.elaborate()).toMatchSnapshot())
@@ -131,7 +131,7 @@ test('Invalid binary type combinations for (-|*|/|%) return TypeError', () => {
131131
const context = mockRuntimeContext()
132132
const errors = operatorValues.map(opVals => {
133133
return rttc.checkBinaryExpression(context, opVals[0] as BinaryOperator, opVals[1], opVals[2])
134-
})
134+
}) as rttc.TypeError[]
135135
errors.map(error => expect(error).toBeInstanceOf(rttc.TypeError))
136136
errors.map(error => expect(error.explain()).toMatchSnapshot())
137137
errors.map(error => expect(error.elaborate()).toMatchSnapshot())
@@ -175,7 +175,7 @@ test('Invalid binary type combinations for (<|>|<==|>==) return TypeError', () =
175175
const context = mockRuntimeContext()
176176
const errors = operatorValues.map(opVals => {
177177
return rttc.checkBinaryExpression(context, opVals[0] as BinaryOperator, opVals[1], opVals[2])
178-
})
178+
}) as rttc.TypeError[]
179179
errors.map(error => expect(error).toBeInstanceOf(rttc.TypeError))
180180
errors.map(error => expect(error.explain()).toMatchSnapshot())
181181
errors.map(error => expect(error.elaborate()).toMatchSnapshot())
@@ -203,7 +203,7 @@ test('Invalid logical type combinations return TypeError', () => {
203203
const context = mockRuntimeContext()
204204
const errors = operatorValues.map(opVals => {
205205
return rttc.checkLogicalExpression(context, opVals[0], opVals[1])
206-
})
206+
}) as rttc.TypeError[]
207207
errors.map(error => expect(error).toBeInstanceOf(rttc.TypeError))
208208
errors.map(error => expect(error.explain()).toMatchSnapshot())
209209
errors.map(error => expect(error.elaborate()).toMatchSnapshot())
@@ -219,7 +219,9 @@ test('Valid ternary/if test expressions are OK', () => {
219219
test('Invalid ternary/if test expressions return TypeError', () => {
220220
const operatorValues = [num, str, func]
221221
const context = mockRuntimeContext()
222-
const errors = operatorValues.map(opVal => rttc.checkIfStatement(context, opVal))
222+
const errors = operatorValues.map(opVal => {
223+
return rttc.checkIfStatement(context, opVal)
224+
}) as rttc.TypeError[]
223225
errors.map(error => expect(error).toBeInstanceOf(rttc.TypeError))
224226
errors.map(error => expect(error.explain()).toMatchSnapshot())
225227
errors.map(error => expect(error.elaborate()).toMatchSnapshot())

0 commit comments

Comments
 (0)