1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-30 04:23:07 +03:00

Improve types and their safety (#3290)

* Improve types and their safety

* Iterate
This commit is contained in:
Michael Telatynski
2023-04-18 08:32:40 +01:00
committed by GitHub
parent 4f67e59692
commit 72d70bb929
4 changed files with 8 additions and 8 deletions

View File

@ -678,14 +678,14 @@ describe("utils", function () {
describe("safeSet", () => {
it("should set a value", () => {
const obj = {};
const obj: Record<string, string> = {};
safeSet(obj, "testProp", "test value");
expect(obj).toEqual({ testProp: "test value" });
});
it.each(["__proto__", "prototype", "constructor"])("should raise an error when setting »%s«", (prop) => {
expect(() => {
safeSet({}, prop, "teset value");
safeSet(<Record<string, string>>{}, prop, "teset value");
}).toThrow("Trying to modify prototype or constructor");
});
});