Skip to content

Commit 1915d77

Browse files
committed
fix: export type and use in tests so TS compiles
1 parent a452f3f commit 1915d77

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

src/service-module/service-module.mutations.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ import _isObject from 'lodash/isObject'
1919
import { Id } from '@feathersjs/feathers'
2020
import { ServiceState } from '..'
2121

22-
type PendingServiceMethodName = 'find' | 'get' | 'create' | 'update' | 'patch' | 'remove'
23-
type PendingIdServiceMethodName = Exclude<PendingServiceMethodName, 'find' | 'get'>
22+
export type PendingServiceMethodName =
23+
| 'find'
24+
| 'get'
25+
| 'create'
26+
| 'update'
27+
| 'patch'
28+
| 'remove'
29+
export type PendingIdServiceMethodName = Exclude<
30+
PendingServiceMethodName,
31+
'find' | 'get'
32+
>
2433

2534
export default function makeServiceMutations() {
2635
function addItems(state, items) {

test/service-module/service-module.mutations.test.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ eslint
55
*/
66
import { assert } from 'chai'
77
import { assertGetter } from '../test-utils'
8-
import makeServiceMutations from '../../src/service-module/service-module.mutations'
8+
import makeServiceMutations, {
9+
PendingServiceMethodName
10+
} from '../../src/service-module/service-module.mutations'
911
import makeServiceState from '../../src/service-module/service-module.state'
1012
import errors from '@feathersjs/errors'
1113
import Vue from 'vue'
@@ -1143,7 +1145,14 @@ describe('Service Module - Mutations', function() {
11431145
describe('Pending', function() {
11441146
it('setPending && unsetPending', function() {
11451147
const state = this.state
1146-
const methods = ['find', 'get', 'create', 'update', 'patch', 'remove']
1148+
const methods: PendingServiceMethodName[] = [
1149+
'find',
1150+
'get',
1151+
'create',
1152+
'update',
1153+
'patch',
1154+
'remove'
1155+
]
11471156

11481157
methods.forEach(method => {
11491158
const uppercaseMethod = method.charAt(0).toUpperCase() + method.slice(1)
@@ -1163,7 +1172,14 @@ describe('Service Module - Mutations', function() {
11631172
describe('Errors', function() {
11641173
it('setError', function() {
11651174
const state = this.state
1166-
const methods = ['find', 'get', 'create', 'update', 'patch', 'remove']
1175+
const methods: PendingServiceMethodName[] = [
1176+
'find',
1177+
'get',
1178+
'create',
1179+
'update',
1180+
'patch',
1181+
'remove'
1182+
]
11671183

11681184
methods.forEach(method => {
11691185
const uppercaseMethod = method.charAt(0).toUpperCase() + method.slice(1)
@@ -1176,7 +1192,14 @@ describe('Service Module - Mutations', function() {
11761192

11771193
it('setError with feathers-errors', function() {
11781194
const state = this.state
1179-
const methods = ['find', 'get', 'create', 'update', 'patch', 'remove']
1195+
const methods: PendingServiceMethodName[] = [
1196+
'find',
1197+
'get',
1198+
'create',
1199+
'update',
1200+
'patch',
1201+
'remove'
1202+
]
11801203

11811204
methods.forEach(method => {
11821205
const uppercaseMethod = method.charAt(0).toUpperCase() + method.slice(1)
@@ -1196,7 +1219,14 @@ describe('Service Module - Mutations', function() {
11961219

11971220
it('clearError', function() {
11981221
const state = this.state
1199-
const methods = ['find', 'get', 'create', 'update', 'patch', 'remove']
1222+
const methods: PendingServiceMethodName[] = [
1223+
'find',
1224+
'get',
1225+
'create',
1226+
'update',
1227+
'patch',
1228+
'remove'
1229+
]
12001230

12011231
methods.forEach(method => {
12021232
const uppercaseMethod = method.charAt(0).toUpperCase() + method.slice(1)

0 commit comments

Comments
 (0)