Skip to content

Commit 3e8c451

Browse files
committed
Generate types during the build target
1 parent 385625e commit 3e8c451

File tree

7 files changed

+32
-20
lines changed

7 files changed

+32
-20
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ Thanks goes to these people ([emoji key][emojis]):
267267

268268
<!-- markdownlint-enable -->
269269
<!-- prettier-ignore-end -->
270+
270271
<!-- ALL-CONTRIBUTORS-LIST:END -->
271272

272273
This project follows the [all-contributors][all-contributors] specification.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
"node": ">=10"
2525
},
2626
"scripts": {
27-
"build": "kcd-scripts build --ignore \"**/__tests__/**,**/__node_tests__/**,**/__mocks__/**\" && kcd-scripts build --bundle --no-clean",
27+
"build": "npm run build:bundles ; npm run build:types",
28+
"build:bundles": "kcd-scripts build --ignore \"**/__tests__/**,**/__node_tests__/**,**/__mocks__/**\" && kcd-scripts build --bundle --no-clean",
29+
"build:types": "tsc --build tsconfig.build.json",
2830
"lint": "kcd-scripts lint",
2931
"setup": "npm install && npm run validate -s",
3032
"test": "kcd-scripts test",
3133
"test:debug": "node --inspect-brk ./node_modules/.bin/jest --watch --runInBand",
3234
"test:update": "npm test -- --updateSnapshot --coverage",
3335
"validate": "kcd-scripts validate",
34-
"generate-types": "tsc",
35-
"typecheck": "dtslint ./types/"
36+
"typecheck-DISABLED": "dtslint ./types/"
3637
},
3738
"files": [
3839
"dist",

src/__tests__/events.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,21 @@ const eventTypes = [
140140

141141
const allEvents = Object.keys(eventMap)
142142

143-
const bubblingEvents = allEvents
144-
.filter(eventName => eventMap[eventName].defaultInit.bubbles)
143+
const bubblingEvents = allEvents.filter(
144+
eventName => eventMap[eventName].defaultInit.bubbles,
145+
)
145146

146-
const composedEvents = allEvents
147-
.filter(eventName => eventMap[eventName].defaultInit.composed)
147+
const composedEvents = allEvents.filter(
148+
eventName => eventMap[eventName].defaultInit.composed,
149+
)
148150

149-
const nonBubblingEvents = allEvents
150-
.filter(eventName => !bubblingEvents.includes(eventName))
151+
const nonBubblingEvents = allEvents.filter(
152+
eventName => !bubblingEvents.includes(eventName),
153+
)
151154

152-
const nonComposedEvents = allEvents
153-
.filter(eventName => !composedEvents.includes(eventName))
155+
const nonComposedEvents = allEvents.filter(
156+
eventName => !composedEvents.includes(eventName),
157+
)
154158

155159
eventTypes.forEach(({type, events, elementType}) => {
156160
describe(`${type} Events`, () => {
@@ -203,7 +207,7 @@ describe(`Composed Events`, () => {
203207
const spy = jest.fn()
204208
node.addEventListener(event.toLowerCase(), spy)
205209

206-
const shadowRoot = node.attachShadow({ mode: 'closed' })
210+
const shadowRoot = node.attachShadow({mode: 'closed'})
207211
const innerNode = document.createElement('div')
208212
shadowRoot.appendChild(innerNode)
209213

@@ -218,7 +222,7 @@ describe(`Composed Events`, () => {
218222
const spy = jest.fn()
219223
node.addEventListener(event.toLowerCase(), spy)
220224

221-
const shadowRoot = node.attachShadow({ mode: 'closed' })
225+
const shadowRoot = node.attachShadow({mode: 'closed'})
222226
const innerNode = document.createElement('div')
223227
shadowRoot.appendChild(innerNode)
224228

@@ -234,7 +238,7 @@ describe(`Aliased Events`, () => {
234238
const node = document.createElement('div')
235239
const spy = jest.fn()
236240
node.addEventListener(eventAliasMap[eventAlias].toLowerCase(), spy)
237-
241+
238242
fireEvent[eventAlias](node)
239243
expect(spy).toHaveBeenCalledTimes(1)
240244
})

src/__tests__/role.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@ Here are the accessible roles:
346346
test('has no useful error message in findBy', async () => {
347347
const {findByRole} = render(`<li />`)
348348

349-
await expect(findByRole('option', {timeout: 1})).rejects.toThrow('Unable to find role="option"')
349+
await expect(findByRole('option', {timeout: 1})).rejects.toThrow(
350+
'Unable to find role="option"',
351+
)
350352
})
351353

352354
test('explicit role is most specific', () => {

src/wait-for.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ interface WaitOptions {
122122
interval?: number
123123
mutationObserverOptions?: MutationObserverInit
124124
}
125-
function wait(
126-
first: () => void = () => {},
127-
options?: WaitOptions,
128-
): Promise<void> {
125+
function wait(first: () => void, options?: WaitOptions): Promise<void> {
129126
// istanbul ignore next
130127
if (!hasWarned) {
131128
hasWarned = true

tsconfig.build.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"emitDeclarationOnly": true
6+
}
7+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"outDir": "./types/",
44
"allowJs": true,
55
"declaration": true,
6-
"emitDeclarationOnly": true,
6+
"noEmit": true,
77
"allowSyntheticDefaultImports": true
88
},
99
"include": ["./src/**/*.ts"]

0 commit comments

Comments
 (0)