Skip to content

Commit c99ad50

Browse files
mattwynnefunficienteoolablaisep
authored
Replace some uses of any type (#1892)
* Replace use of `any` type with `messages.Envelope` Part of #1648 Co-authored-by: Kate Dames <[email protected]> Co-authored-by: Emmanuel Ola <[email protected]> * Replace use of `any` with a custom World in CCK example Part of #1648 Co-authored-by: Emmanuel Ola <[email protected]> Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Kate Dames <[email protected]> * Replace another use of `any` with a custom type Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Kate Dames <[email protected]> * Replace another use of `any` type Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Kate Dames <[email protected]> Co-authored-by: Kate Dames <[email protected]> Co-authored-by: Emmanuel Ola <[email protected]> Co-authored-by: Blaise Pabon <[email protected]>
1 parent aa1d65c commit c99ad50

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

compatibility/cck_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('Cucumber Compatibility Kit', () => {
5858
stdout.end()
5959

6060
const rawOutput = await toString(stdout)
61+
// TODO: consider validating (at run-time) the parsed message is really an Envelope
6162
const actualMessages = normalize(
6263
rawOutput
6364
.split('\n')
@@ -85,7 +86,7 @@ describe('Cucumber Compatibility Kit', () => {
8586
})
8687
})
8788

88-
function normalize(messages: any[]): any[] {
89+
function normalize(messages: messages.Envelope[]): messages.Envelope[] {
8990
messages = normalizeMessageOutput(
9091
messages,
9192
path.join(PROJECT_PATH, 'compatibility')
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { When, Then, DataTable } from '../../../src'
22
import { expect } from 'chai'
33

4+
type World = {
5+
transposed: DataTable
6+
}
7+
48
When(
59
'the following table is transposed:',
6-
function (this: any, table: DataTable) {
10+
function (this: World, table: DataTable) {
711
this.transposed = table.transpose()
812
}
913
)
1014

11-
Then('it should be:', function (this: any, expected: DataTable) {
15+
Then('it should be:', function (this: World, expected: DataTable) {
1216
expect(this.transposed.raw()).to.deep.eq(expected.raw())
1317
})
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
import assert from 'assert'
22
import { Given, When, Then } from '../../../src'
33

4-
Given('there are {int} cucumbers', function (this: any, initialCount: number) {
5-
this.count = initialCount
6-
})
4+
type World = {
5+
count: number
6+
}
7+
8+
Given(
9+
'there are {int} cucumbers',
10+
function (this: World, initialCount: number) {
11+
this.count = initialCount
12+
}
13+
)
714

8-
When('I eat {int} cucumbers', function (this: any, eatCount: number) {
15+
When('I eat {int} cucumbers', function (this: World, eatCount: number) {
916
this.count -= eatCount
1017
})
1118

1219
Then(
1320
'I should have {int} cucumbers',
14-
function (this: any, expectedCount: number) {
21+
function (this: World, expectedCount: number) {
1522
assert.strictEqual(this.count, expectedCount)
1623
}
1724
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Given } from '../../../src'
22

33
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4-
Given('{airport} is closed because of a strike', function (airport: any) {
4+
Given('{airport} is closed because of a strike', function (airport: unknown) {
55
throw new Error('Should not be called because airport type not defined')
66
})

0 commit comments

Comments
 (0)