Skip to content

Commit

Permalink
remove typeName from options object for defineParameterType (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss authored May 9, 2020
1 parent 3b0b33b commit a4716c0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
* `event-protocol` formatter has been removed and replaced with `message`
* Custom formatters will need to migrate
* `json` formatter is deprecated and will be removed in next major release. Custom formatters should migrate to use the `message` formatter, or the [standalone JSON formatter](https://github.com/cucumber/cucumber/tree/master/json-formatter) as a stopgap.
* Remove long-deprecated `typeName` from options object for `defineParameterType` in favour of `name`

#### Bug fixes

Expand Down
15 changes: 1 addition & 14 deletions src/support_code_library_builder/build_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { deprecate } from 'util'
import _ from 'lodash'
import { ParameterType } from 'cucumber-expressions'
import path from 'path'
import StackTrace from 'stacktrace-js'
import { isFileNameInCucumber } from '../stack_trace_filter'
import {
doesHaveValue,
doesNotHaveValue,
valueOrDefault,
} from '../value_checker'
import { doesHaveValue, valueOrDefault } from '../value_checker'
import { ILineAndUri } from '../types'
import { IParameterTypeDefinition } from './types'

Expand All @@ -34,19 +29,11 @@ export function getDefinitionLineAndUri(cwd: string): ILineAndUri {

export function buildParameterType({
name,
typeName,
regexp,
transformer,
useForSnippets,
preferForRegexpMatch,
}: IParameterTypeDefinition<any>): ParameterType<any> {
const getTypeName = deprecate(
() => typeName,
'Cucumber defineParameterType: Use name instead of typeName'
)
if (doesNotHaveValue(name) && doesHaveValue(typeName)) {
name = getTypeName()
}
if (typeof useForSnippets !== 'boolean') useForSnippets = true
if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false
return new ParameterType(
Expand Down
1 change: 0 additions & 1 deletion src/support_code_library_builder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface IDefineTestRunHookOptions {

export interface IParameterTypeDefinition<T> {
name: string
typeName: string
regexp: RegExp
transformer: (...match: string[]) => T
useForSnippets: boolean
Expand Down

0 comments on commit a4716c0

Please sign in to comment.