Coder Social home page Coder Social logo

Comments (2)

tommedema avatar tommedema commented on June 15, 2024

Alternatively, if it is possible to simply not return function definitions instead of throwing UnknownTypeError: Unknown type "function"" that would also work for my use case

from ts-json-schema-generator.

tommedema avatar tommedema commented on June 15, 2024

This only occured on one file, I don't know why, but I suppose it is practical to just ignore it:

import { type Dispatch, type Middleware, isAction } from '@reduxjs/toolkit'
import objectPath from 'object-path'
import { type ReduxAction, type RootState, isReduxAction } from '../../../lib/types.js'
import viewNamespace from '../../__view/index.js'
import reduxNamespace from '../index.js'

const { setStatePathResult } = viewNamespace.actions
const { _broadcastAllSagasFulfilled } = reduxNamespace.actions

export const stateObjectPathMiddleware: Middleware<unknown, RootState, Dispatch<ReduxAction>> = (storeApi) => (next) => (action) => {
  const result = next(action)

  let state: RootState | null = null
  let statePath: string | null = null

  // Set statePath if we need to set the path result
  if (isReduxAction(action) && action.type !== setStatePathResult.type) {
    statePath = action.meta.selectStatePath
  } else if (isAction(action) && action.type === _broadcastAllSagasFulfilled.type) {
    // Update the path result to the latest once async work has completed
    state = storeApi.getState()
    statePath = state.__view.statePath
  }

  // Set the path result if statePath is set
  if (typeof statePath === 'string') {
    if (state == null) {
      state = storeApi.getState()
    }

    const pathResult = objectPath.get(state, statePath)

    storeApi.dispatch({
      ...setStatePathResult({ pathResult, statePath }),
      meta: {
        selectStatePath: null
      }
    })
  }

  return result
}

from ts-json-schema-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.