I'm using JSDoc & TSDoc on a react native project.
Here is the file:
import React, { createContext, useContext, FC } from 'react'
import useUserData, { UseUserDataType } from './useUserData'
import { AuthContext } from './FirebaseContextProvider'
import { AuthUser } from '../../common'
// Initial state
const initialUserDataContext = {
userData: {},
} as UseUserDataType
// Create the context objects
export const UserDataContext = createContext<UseUserDataType>(initialUserDataContext)
/**
* Context provider for user data from firebase
*
* @param props -
* @param props.children - application parts that are dependent on user data.
* @returns a context provider for user data
*/
const DataContextProvider: FC = ({ children }) => {
const { user } = useContext(AuthContext)
// UserData
const userData = useUserData(user as AuthUser)
return (
<UserDataContext.Provider value={userData}>
{children}
</UserDataContext.Provider>
)
}
export default DataContextProvider
I have two warnings:
On the second @param:
tsdoc-param-tag-with-invalid-name: The @param block should be followed by a valid parameter name: The identifier cannot non-word characterseslinttsdoc/syntax
On the begining of the JSDoc lines:
Missing JSDoc @param "props.children" type.eslintjsdoc/require-param-type
I'm not really getting how I shall document the props I guess. Any insights ?
Thanks
Edit:
If I add the types as @param {Type}, TSDoc complain because it is TypeScript:
tsdoc-param-tag-with-invalid-type: The @param block should not include a JSDoc-style '{type}'eslinttsdoc/syntax
For the time being I deleted the rules, waiting to see if there is a better configuration.
'jsdoc/require-returns-type': 'off',
'jsdoc/require-returns-type': 'off',
This might be a little old but for those who run into similar issues.
Sheraff was right in the comment so I'd like to expand.
Let's first look at the error/s:
So that means you are missing the parameters type.
Then:
This means this:
Should be this without text after the param name:
Then finally this:
This means you have added a type - {type} - which is not a recognised type. A valid type means String, Int, Object and this is NOT because you are using TS. It's JSDoc needs them signatured.
So to fix I believe the below would do it: