Skip to content

Commit 0445c6e

Browse files
committed
Fix typescript nulls
1 parent cb74356 commit 0445c6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+242
-180
lines changed

.mocharc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"require": [
33
"ts-node/register",
44
"source-map-support/register",
5-
"./css-modules-hook.js",
5+
"./css-modules-hook.cjs",
66
"global-jsdom/register"
77
],
88
"extension": ["ts", "tsx"],
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
export const parameters = {
33
actions: { argTypesRegex: "^on[A-Z].*" },
4-
}
4+
}

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FEATURE_FILES = $(sort $(wildcard node_modules/@cucumber/compatibility-kit/javascript/features/**/*.ndjson))
2-
TS_MESSAGE_FILES = $(patsubst node_modules/@cucumber/compatibility-kit/javascript/features/%.ndjson,acceptance/%.ts,$(FEATURE_FILES))
1+
FEATURE_FILES = $(sort $(wildcard node_modules/@cucumber/compatibility-kit/features/**/*.ndjson))
2+
TS_MESSAGE_FILES = $(patsubst node_modules/@cucumber/compatibility-kit/features/%.ndjson,acceptance/%.ts,$(FEATURE_FILES))
33

44
default: .codegen .tested
55

66
.codegen: $(TS_MESSAGE_FILES)
77

88
# Convert an .ndjson file to a .ts file with Envelope objects that can be imported
9-
acceptance/%.ts: node_modules/@cucumber/compatibility-kit/javascript/features/%.ndjson Makefile
9+
acceptance/%.ts: node_modules/@cucumber/compatibility-kit/features/%.ndjson Makefile
1010
mkdir -p $(@D)
1111
echo "// Generated file. Do not edit." > $@
1212
echo "export default [" >> $@

css-modules-hook.js renamed to css-modules-hook.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ hook({
1111
}).css
1212
},
1313
generateScopedName: '[local]__generated',
14-
});
14+
});

package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22
"name": "@cucumber/react",
33
"version": "18.1.2",
44
"description": "React components for Cucumber",
5-
"main": "dist/src/index.js",
6-
"types": "dist/src/index.d.ts",
5+
"type": "module",
6+
"main": "dist/cjs/src/index.js",
7+
"types": "dist/cjs/src/index.d.ts",
8+
"files": [
9+
"dist/cjs",
10+
"dist/esm"
11+
],
12+
"module": "dist/esm/src/index.js",
13+
"jsnext:main": "dist/esm/src/index.js",
14+
"exports": {
15+
".": {
16+
"import": "./dist/esm/src/index.js",
17+
"require": "./dist/cjs/src/index.js"
18+
}
19+
},
720
"repository": {
821
"type": "git",
922
"url": "git+https://github.com/cucumber/cucumber.git"

src/EnvelopesQueryContext.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ export class EnvelopesQuery {
88
this.envelopes.push(envelope)
99
}
1010

11-
public find(predicate: (envelope: messages.Envelope) => boolean): messages.Envelope {
11+
public find(predicate: (envelope: messages.Envelope) => boolean): messages.Envelope | undefined {
1212
return this.envelopes.find(predicate)
1313
}
1414

1515
public filter(predicate: (envelope: messages.Envelope) => boolean): messages.Envelope[] {
1616
return this.envelopes.filter(predicate)
1717
}
1818

19-
public getMeta(): messages.Meta {
19+
public getMeta(): messages.Meta | undefined {
2020
return this.find((envelope) => !!envelope.meta)?.meta
2121
}
2222

23-
public getTestRunStarted(): messages.TestRunStarted {
23+
public getTestRunStarted(): messages.TestRunStarted | undefined {
2424
return this.find((envelope) => !!envelope.testRunStarted)?.testRunStarted
2525
}
2626

27-
public getTestRunFinished(): messages.TestRunFinished {
27+
public getTestRunFinished(): messages.TestRunFinished | undefined {
2828
return this.find((envelope) => !!envelope.testRunFinished)?.testRunFinished
2929
}
3030
}

src/SearchQueryContext.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const defaultQuery = ''
88
const defaultHideStatuses: Status[] = []
99

1010
export interface SearchQueryUpdate {
11-
readonly query?: string
11+
readonly query?: string | null
1212
readonly hideStatuses?: readonly Status[]
1313
}
1414

@@ -70,14 +70,14 @@ export function searchFromURLParams(opts?: {
7070

7171
function toSearchQuery(iQuery?: SearchQueryUpdate): SearchQuery {
7272
return {
73-
query: iQuery.query ?? defaultQuery,
74-
hideStatuses: iQuery.hideStatuses ?? defaultHideStatuses,
73+
query: iQuery?.query ?? defaultQuery,
74+
hideStatuses: iQuery?.hideStatuses ?? defaultHideStatuses,
7575
}
7676
}
7777

7878
export class SearchQueryCtx implements SearchQuery {
7979
readonly query: string
80-
readonly hideStatuses: readonly Status[] | null
80+
readonly hideStatuses: readonly Status[]
8181
readonly update: (query: SearchQueryUpdate) => void
8282

8383
constructor(value: SearchQuery, updateValue: SearchQueryUpdateFn) {
@@ -92,7 +92,7 @@ export class SearchQueryCtx implements SearchQuery {
9292
}
9393

9494
static withDefaults = (
95-
value: SearchQueryUpdate,
95+
value: SearchQueryUpdate = {},
9696
onSearchQueryUpdated: SearchQueryUpdateFn = () => {
9797
//Do nothing
9898
}
@@ -107,9 +107,9 @@ export function useSearchQueryCtx(props: SearchQueryProps): SearchQueryCtx {
107107
searchQuery,
108108
props.onSearchQueryUpdated
109109
? (query) => {
110-
props.onSearchQueryUpdated(query)
111-
setSearchQuery(query)
112-
}
110+
props.onSearchQueryUpdated && props.onSearchQueryUpdated(query)
111+
setSearchQuery(query)
112+
}
113113
: setSearchQuery
114114
)
115115
}

src/UriContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import React from 'react'
22

3-
export default React.createContext(null as string)
3+
export default React.createContext<null|string>(null)

src/components/app/CICommitLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface IProps {
1111
export const CICommitLink: React.FunctionComponent<IProps> = ({ ci: ci }) => {
1212
const commitLink = ciCommitLink(ci)
1313

14-
if (commitLink) {
14+
if (commitLink && ci.git?.remote) {
1515
return (
1616
<>
1717
<FontAwesomeIcon icon={faLink} />
@@ -21,7 +21,7 @@ export const CICommitLink: React.FunctionComponent<IProps> = ({ ci: ci }) => {
2121
}
2222
return (
2323
<>
24-
<FontAwesomeIcon icon={faLink} /> {ci.git.revision.substring(0, 7)}
24+
<FontAwesomeIcon icon={faLink} /> {ci.git?.revision.substring(0, 7)}
2525
</>
2626
)
2727
}

0 commit comments

Comments
 (0)