type NewData = {
id?: null|undefined,
[propName: string]: unknown
}type NewData = {
id: never,
[propName: string]: unknown
}
type CreatedData = {
id: number | string
[propName: string]: unknown
}
export async function create (path: string, data: NewData) {
return (await api.post(`${path}`, data)).data.data
}
export async function update (path: string, data: CreatedData) {
return (await api.put(`${path}/${data.id}`, data)).data.data
}
export async function upsert (path: string, data: NewData | CreatedData) {
if ("id" in data) {
return await update(path, data)
} else {
return await create(path, data)
}
}
export async function upsert (path: string, data: Type1|Type2 ) {
if ((data.id !== undefined): data is Type1) {
return await update(path, data)
} else (data is Type2) {
return await create(path, data)
}
} @services ругаться надо. А инклюд у меня вообще пустой был. И при этом всё собиралось и работало о_О import { lowercasedObject, notifyError, pageHeightFn } from '@/services' ведь его не было в include (он вообще был пропущен), а в paths было так:"paths": {
"@/*": ["resources/spa/*"]
}, "include": [
"./resources/**/*.ts",
"./resources/**/*.vue"
],При отправке статус доставки узнать невозможно.