Skip to content

Commit 273cc06

Browse files
Extract type of updateProfileData’s function param
I didn’t really want to do this, but with the TypeDoc configuration that I intend to use (i.e. with `"validation": true` and `requiredToBeDocumented` populated with all types) it seems unavoidable, else I get an error of the form > [warning] Space.updateProfileData.updateFn.__type, defined in ./dist/mjs/Space.d.ts, does not have any documentation. I could not figure out how to satisfy this warning without creating a type for this callback. I think that in a codebase which makes heavy use of callbacks this would not be ideal, but I guess we can live with it in our codebase, where there are few callbacks. The alternative would be to try and change the TypeDoc configuration, but I couldn’t find a non-trivial requiredToBeDocumented value which made the warning go away. And I don’t really want to make requiredToBeDocumented trivial nor turn off the `validation` option. It’s a shame that, as far as I can tell, TypeDoc doesn’t offer the option of suppressing a warning for a single symbol.
1 parent 0c7fb06 commit 273cc06

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Space.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface SpaceState {
3838
members: SpaceMember[];
3939
}
4040

41+
export type UpdateProfileDataFunction = (profileData: ProfileData) => ProfileData;
42+
4143
class Space extends EventEmitter<SpaceEventMap> {
4244
/**
4345
* @internal
@@ -142,8 +144,8 @@ class Space extends EventEmitter<SpaceEventMap> {
142144
}
143145

144146
async updateProfileData(profileData: ProfileData): Promise<void>;
145-
async updateProfileData(updateFn: (update: ProfileData) => ProfileData): Promise<void>;
146-
async updateProfileData(profileDataOrUpdateFn: ProfileData | ((update: ProfileData) => ProfileData)): Promise<void> {
147+
async updateProfileData(updateFn: UpdateProfileDataFunction): Promise<void>;
148+
async updateProfileData(profileDataOrUpdateFn: ProfileData | UpdateProfileDataFunction): Promise<void> {
147149
const self = await this.members.getSelf();
148150

149151
if (!isObject(profileDataOrUpdateFn) && !isFunction(profileDataOrUpdateFn)) {

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Spaces from './Spaces.js';
22

3-
export type { default as Space, SpaceEventMap, SpaceEvents, SpaceState } from './Space.js';
3+
export type { default as Space, SpaceEventMap, SpaceEvents, SpaceState, UpdateProfileDataFunction } from './Space.js';
44

55
export type { default as Cursors, CursorsEventMap } from './Cursors.js';
66
export type { default as Locations, LocationsEventMap, LocationsEvents } from './Locations.js';

0 commit comments

Comments
 (0)