# Error occurs when using vtkPixelSpaceCallbackMapper with TypeScript

**URL:** https://discourse.vtk.org/t/error-occurs-when-using-vtkpixelspacecallbackmapper-with-typescript/12853
**Category:** vtk.js
**Tags:** bug
**Created:** [December 6, 2023, 1:32am UTC](https://discourse.vtk.org/t/error-occurs-when-using-vtkpixelspacecallbackmapper-with-typescript/12853 "2023-12-06T01:32:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mkubota](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mkubota](https://discourse.vtk.org/u/mkubota)
#### Post date: [December 6, 2023, 1:32am UTC](https://discourse.vtk.org/t/error-occurs-when-using-vtkpixelspacecallbackmapper-with-typescript/12853/1 "2023-12-06T01:32:28Z")

</div>

I tried [this example](https://kitware.github.io/vtk-js/examples/SpheresAndLabels.html) in typescript, but below error occured.

```auto
SphereAndLabels.ts:44:22 - error TS2345: Argument of type '(coordsList: any) => void' is not assignable to parameter of
type '() => any'.
  Target signature provides too few arguments. Expected 1 or more, but got 0.

44 psMapper.setCallback((coordsList) => {

```

Maybe lacking of type difinitions for parameters of callback in index.d.ts files causes this error.

```auto
/**
 * Set the callback function the mapper will call, during the rendering
 * process, with the screen coords of the points in dataset. The callback
 * function will have the following parameters:
 * 
 * // An array of 4-component arrays, in the index-order of the datasets points
 * 
 * coords: [
 * [screenx, screeny, screenz, zBufValue],
 * ...
 * ]

 * // The active camera of the renderer, in case you may need to compute alternate
 * // depth values for your dataset points. Using the sphere mapper in your
 * // application code is one example where this may be useful, so that you can
 * // account for that mapper's radius when doing depth checks.
 * 
 * camera: vtkCamera

 * // The aspect ratio of the render view and depthBuffer
 * aspect: float

 * // A Uint8Array of size width * height * 4, where the zbuffer values are
 * // encoded in the red and green components of each pixel. This will only
 * // be non-null after you call setUseZValues(true) on the mapper before
 * // rendering.
 * 
 * depthBuffer: Uint8Array
 * 
 * @param callback 
 */
setCallback(callback: () => any): boolean

```

---

<div class="post-metadata">

### Author: ![mkubota](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mkubota](https://discourse.vtk.org/u/mkubota)
#### Post date: [December 25, 2023, 4:36am UTC](https://discourse.vtk.org/t/error-occurs-when-using-vtkpixelspacecallbackmapper-with-typescript/12853/2 "2023-12-25T04:36:53Z")

</div>

I added paramters and types as below, then it works well.

```auto
	//setCallback(callback: () => any): boolean
	setCallback(callback: (coords: any, camera: vtkCamera, aspect: number, depthValues: number[]) => any): boolean	

```

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [December 28, 2023, 8:51pm UTC](https://discourse.vtk.org/t/error-occurs-when-using-vtkpixelspacecallbackmapper-with-typescript/12853/3 "2023-12-28T20:51:18Z")

</div>

Feel free to submit a PR with the proper type definition
