My goal is to pass a variable to an RTK Query API service that uses a typescript interface:
const device_id: unique symbol = Symbol(props.id);
const {
data: device,
isFetching,
isLoading,
} = useGetAssetsByIdQuery(device_id, {
pollingInterval: 3000,
refetchOnMountOrArgChange: true,
skip: false,
})
The code snippet above shows how I am converting the props.id
value (which is in string format) into a unique symbol to adhere to the typescript requirements of the useGetAssetsByIdQuery
method.
However, I encountered this error message:
TS2345: Argument of type 'unique symbol' is not assignable to parameter of type 'GetAssetsByIdApiArg | unique symbol'.
I'm puzzled as to why the error occurs since I'm passing a unique symbol
, which is one of the expected types according to the interface specifications allowing for either GetAssetsByIdApiArg
or unique symbol
.