You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Improve types and their safety (#3290)
* Improve types and their safety * Iterate
This commit is contained in:
committed by
GitHub
parent
4f67e59692
commit
72d70bb929
@@ -720,7 +720,7 @@ function processMapToObjectValue(value: any): any {
|
||||
* Recursively converts Maps to plain objects.
|
||||
* Also supports sub-lists of Maps.
|
||||
*/
|
||||
export function recursiveMapToObject(map: Map<any, any>): any {
|
||||
export function recursiveMapToObject(map: Map<any, any>): Record<any, any> {
|
||||
const targetMap = new Map();
|
||||
|
||||
for (const [key, value] of map) {
|
||||
@@ -734,7 +734,7 @@ export function unsafeProp<K extends keyof any | undefined>(prop: K): boolean {
|
||||
return prop === "__proto__" || prop === "prototype" || prop === "constructor";
|
||||
}
|
||||
|
||||
export function safeSet<K extends keyof any>(obj: Record<any, any>, prop: K, value: any): void {
|
||||
export function safeSet<O extends Record<any, any>, K extends keyof O>(obj: O, prop: K, value: O[K]): void {
|
||||
if (unsafeProp(prop)) {
|
||||
throw new Error("Trying to modify prototype or constructor");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user