Skip to content

Commit

Permalink
Unify userData property type (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 authored Nov 27, 2023
1 parent f8293b7 commit bc7a6e8
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion types/three/examples/jsm/loaders/GLTFLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface GLTF {
extras?: any;
};
parser: GLTFParser;
userData: any;
userData: Record<string, any>;
}

export class GLTFLoader extends Loader<GLTF> {
Expand Down
6 changes: 1 addition & 5 deletions types/three/examples/jsm/loaders/SVGLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Loader, LoadingManager, ShapePath, BufferGeometry, Vector3, Shape, Vector2 } from '../../../src/Three.js';

export interface SVGResultPaths extends ShapePath {
userData?:
| {
[key: string]: any;
}
| undefined;
userData?: Record<string, any> | undefined;
}

export interface SVGResult {
Expand Down
4 changes: 1 addition & 3 deletions types/three/examples/jsm/nodes/core/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ export type NodeTypeOption =
export type SwizzleOption = string;

/** Should be the same type as Object3D.userData */
export interface NodeUserData {
[key: string]: any;
}
export type NodeUserData = Record<string, any>;

/** generic key value type,curretly used by nodes */
export interface AnyObject {
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/core/BufferGeometry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class BufferGeometry<
* An object that can be used to store custom data about the BufferGeometry. It should not hold references to functions as these will not be cloned.
* @defaultValue `{}`
*/
userData: { [key: string]: any };
userData: Record<string, any>;

/**
* Read-only flag to check if a given object is of type {@link BufferGeometry}.
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/core/Object3D.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap> ext
* @remarks It should not hold references to _functions_ as these **will not** be cloned.
* @default `{}`
*/
userData: { [key: string]: any }; // TODO Replace this to a Record?
userData: Record<string, any>;

/**
* Custom depth material to be used when rendering to the depth map.
Expand Down
4 changes: 2 additions & 2 deletions types/three/src/materials/Material.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface MaterialParameters {
stencilFail?: StencilOp | undefined;
stencilZFail?: StencilOp | undefined;
stencilZPass?: StencilOp | undefined;
userData?: any;
userData?: Record<string, any> | undefined;
}

/**
Expand Down Expand Up @@ -379,7 +379,7 @@ export class Material extends EventDispatcher<{ dispose: {} }> {
* An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned.
* @default {}
*/
userData: any;
userData: Record<string, any>;

/**
* This starts at 0 and counts how many times .needsUpdate is set to true.
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/textures/Texture.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export class Texture extends EventDispatcher<{ dispose: {} }> {
* @remarks It should not hold references to functions as these will not be cloned.
* @defaultValue `{}`
*/
userData: any;
userData: Record<string, any>;

/**
* This starts at `0` and counts how many times {@link needsUpdate | .needsUpdate} is set to `true`.
Expand Down

0 comments on commit bc7a6e8

Please sign in to comment.