fix: resolve TypeScript type errors across codebase
- Add experimentalDecorators support in tsconfig.node.json for TypeORM entities - Fix mssql module import in order-resolver.ts (static vs dynamic import) - Extend ISqlType parameter types in sql-server.ts for NVarChar compatibility - Fix variable naming and type assertions in bip-users-dao.ts - Add proper type assertions for IPC call results in renderer hooks (useAuth, useCleaner, useExtractor, useValidation) - Add definite assignment assertions in config-manager.ts
This commit is contained in:
@@ -53,7 +53,11 @@ export function useAuth(): UseAuthReturn {
|
||||
setState((prev) => ({ ...prev, loading: true, error: null }))
|
||||
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('auth:login', credentials)
|
||||
const result = (await window.electron.ipcRenderer.invoke('auth:login', credentials)) as {
|
||||
success: boolean
|
||||
userInfo?: UserInfo
|
||||
error?: string
|
||||
}
|
||||
|
||||
if (result.success && result.userInfo) {
|
||||
setState({
|
||||
@@ -85,7 +89,12 @@ export function useAuth(): UseAuthReturn {
|
||||
setState((prev) => ({ ...prev, loading: true, error: null }))
|
||||
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('auth:silentLogin')
|
||||
const result = (await window.electron.ipcRenderer.invoke('auth:silentLogin')) as {
|
||||
success: boolean
|
||||
userInfo?: UserInfo
|
||||
error?: string
|
||||
requiresUserSelection?: boolean
|
||||
}
|
||||
|
||||
if (result.success && result.userInfo) {
|
||||
setState({
|
||||
@@ -126,14 +135,18 @@ export function useAuth(): UseAuthReturn {
|
||||
|
||||
const getCurrentUser = useCallback(async (): Promise<UserInfo | null> => {
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('auth:getCurrentUser')
|
||||
const result = (await window.electron.ipcRenderer.invoke('auth:getCurrentUser')) as {
|
||||
isAuthenticated: boolean
|
||||
userInfo?: UserInfo
|
||||
}
|
||||
if (result.isAuthenticated && result.userInfo) {
|
||||
const userInfo = result.userInfo
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
user: result.userInfo,
|
||||
user: userInfo,
|
||||
isAuthenticated: true
|
||||
}))
|
||||
return result.userInfo
|
||||
return userInfo
|
||||
}
|
||||
return null
|
||||
} catch {
|
||||
@@ -143,7 +156,7 @@ export function useAuth(): UseAuthReturn {
|
||||
|
||||
const getAllUsers = useCallback(async (): Promise<UserInfo[]> => {
|
||||
try {
|
||||
return await window.electron.ipcRenderer.invoke('auth:getAllUsers')
|
||||
return (await window.electron.ipcRenderer.invoke('auth:getAllUsers')) as UserInfo[]
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
@@ -153,7 +166,11 @@ export function useAuth(): UseAuthReturn {
|
||||
setState((prev) => ({ ...prev, loading: true, error: null }))
|
||||
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('auth:switchUser', userInfo)
|
||||
const result = (await window.electron.ipcRenderer.invoke('auth:switchUser', userInfo)) as {
|
||||
success: boolean
|
||||
userInfo?: UserInfo
|
||||
error?: string
|
||||
}
|
||||
|
||||
if (result.success && result.userInfo) {
|
||||
setState({
|
||||
@@ -180,7 +197,7 @@ export function useAuth(): UseAuthReturn {
|
||||
|
||||
const isAdmin = useCallback(async (): Promise<boolean> => {
|
||||
try {
|
||||
return await window.electron.ipcRenderer.invoke('auth:isAdmin')
|
||||
return (await window.electron.ipcRenderer.invoke('auth:isAdmin')) as boolean
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -44,9 +44,13 @@ export function useCleaner(): UseCleanerReturn {
|
||||
setState({ loading: true, data: null, error: null })
|
||||
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('cleaner:run', input)
|
||||
const result = (await window.electron.ipcRenderer.invoke('cleaner:run', input)) as {
|
||||
success: boolean
|
||||
data?: CleanerResult
|
||||
error?: string
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
if (result.success && result.data) {
|
||||
setState({ loading: false, data: result.data, error: null })
|
||||
return result.data
|
||||
} else {
|
||||
|
||||
@@ -43,9 +43,13 @@ export function useExtractor(): UseExtractorReturn {
|
||||
setState({ loading: true, data: null, error: null })
|
||||
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('extractor:run', input)
|
||||
const result = (await window.electron.ipcRenderer.invoke('extractor:run', input)) as {
|
||||
success: boolean
|
||||
data?: ExtractorResult
|
||||
error?: string
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
if (result.success && result.data) {
|
||||
setState({ loading: false, data: result.data, error: null })
|
||||
return result.data
|
||||
} else {
|
||||
|
||||
@@ -68,13 +68,18 @@ export function useValidation(): UseValidationReturn {
|
||||
setState((prev) => ({ ...prev, loading: true, error: null }))
|
||||
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('validation:validate', request)
|
||||
const result = (await window.electron.ipcRenderer.invoke(
|
||||
'validation:validate',
|
||||
request
|
||||
)) as ValidationResponse
|
||||
|
||||
if (result.success) {
|
||||
const results = result.results || null
|
||||
const stats = result.stats || null
|
||||
setState({
|
||||
loading: false,
|
||||
data: result.results || null,
|
||||
stats: result.stats || null,
|
||||
data: results,
|
||||
stats: stats,
|
||||
error: null
|
||||
})
|
||||
return result
|
||||
@@ -105,7 +110,9 @@ export function useValidation(): UseValidationReturn {
|
||||
|
||||
const getSharedProductionIds = useCallback(async (): Promise<string[]> => {
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('validation:getSharedProductionIds')
|
||||
const result = (await window.electron.ipcRenderer.invoke(
|
||||
'validation:getSharedProductionIds'
|
||||
)) as { productionIds?: string[] }
|
||||
return result?.productionIds || []
|
||||
} catch {
|
||||
return []
|
||||
@@ -117,7 +124,11 @@ export function useValidation(): UseValidationReturn {
|
||||
materialCodes: string[]
|
||||
} | null> => {
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('validation:getCleanerData')
|
||||
const result = (await window.electron.ipcRenderer.invoke('validation:getCleanerData')) as {
|
||||
success: boolean
|
||||
orderNumbers?: string[]
|
||||
materialCodes?: string[]
|
||||
}
|
||||
if (result.success) {
|
||||
return {
|
||||
orderNumbers: result.orderNumbers || [],
|
||||
|
||||
Reference in New Issue
Block a user