Upgrade to TypeScript 7 (#34208)
* Upgrade to TypeScript 7 for massive tsc speed gains Those on WebStorm will want to upgrade to EAP to reap the benefits of the new TSGo compiler Some things (module-api & shared-components) which utilise unplugin-dts (and api-extractor) need to hold a copy of ts6 for its conventional lib format and API. TS7 ships with no API until TS7.1. Other things which use eslint also need ts6 for typescript-eslint. Some type changes were necessary as TS7 caught some issues. * Add knip exception * Fix bad merge
This commit is contained in:
@@ -9,7 +9,12 @@ Please see LICENSE files in the repository root for full details.
|
||||
import IncompatibleController from "../../../../src/settings/controllers/IncompatibleController";
|
||||
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import { type FeatureSettingKey } from "../../../../src/settings/Settings.tsx";
|
||||
|
||||
declare module "../../../../src/settings/Settings.tsx" {
|
||||
interface Settings {
|
||||
test_setting: IBaseSetting<string>;
|
||||
}
|
||||
}
|
||||
|
||||
describe("IncompatibleController", () => {
|
||||
const settingsGetValueSpy = jest.spyOn(SettingsStore, "getValue");
|
||||
@@ -21,17 +26,17 @@ describe("IncompatibleController", () => {
|
||||
describe("when incompatibleValue is not set", () => {
|
||||
it("returns true when setting value is true", () => {
|
||||
// no incompatible value set, defaulted to true
|
||||
const controller = new IncompatibleController("feature_spotlight" as FeatureSettingKey, { key: null });
|
||||
const controller = new IncompatibleController("test_setting", { key: null });
|
||||
settingsGetValueSpy.mockReturnValue(true);
|
||||
// true === true
|
||||
expect(controller.incompatibleSetting).toBe(true);
|
||||
expect(controller.settingDisabled).toEqual(true);
|
||||
expect(settingsGetValueSpy).toHaveBeenCalledWith("feature_spotlight");
|
||||
expect(settingsGetValueSpy).toHaveBeenCalledWith("test_setting");
|
||||
});
|
||||
|
||||
it("returns false when setting value is not true", () => {
|
||||
// no incompatible value set, defaulted to true
|
||||
const controller = new IncompatibleController("feature_spotlight" as FeatureSettingKey, { key: null });
|
||||
const controller = new IncompatibleController("test_setting", { key: null });
|
||||
settingsGetValueSpy.mockReturnValue("test");
|
||||
expect(controller.incompatibleSetting).toBe(false);
|
||||
});
|
||||
@@ -39,21 +44,13 @@ describe("IncompatibleController", () => {
|
||||
|
||||
describe("when incompatibleValue is set to a value", () => {
|
||||
it("returns true when setting value matches incompatible value", () => {
|
||||
const controller = new IncompatibleController(
|
||||
"feature_spotlight" as FeatureSettingKey,
|
||||
{ key: null },
|
||||
"test",
|
||||
);
|
||||
const controller = new IncompatibleController("test_setting", { key: null }, "test");
|
||||
settingsGetValueSpy.mockReturnValue("test");
|
||||
expect(controller.incompatibleSetting).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when setting value is not true", () => {
|
||||
const controller = new IncompatibleController(
|
||||
"feature_spotlight" as FeatureSettingKey,
|
||||
{ key: null },
|
||||
"test",
|
||||
);
|
||||
const controller = new IncompatibleController("test_setting", { key: null }, "test");
|
||||
settingsGetValueSpy.mockReturnValue("not test");
|
||||
expect(controller.incompatibleSetting).toBe(false);
|
||||
});
|
||||
@@ -62,11 +59,7 @@ describe("IncompatibleController", () => {
|
||||
describe("when incompatibleValue is set to a function", () => {
|
||||
it("returns result from incompatibleValue function", () => {
|
||||
const incompatibleValueFn = jest.fn().mockReturnValue(false);
|
||||
const controller = new IncompatibleController(
|
||||
"feature_spotlight" as FeatureSettingKey,
|
||||
{ key: null },
|
||||
incompatibleValueFn,
|
||||
);
|
||||
const controller = new IncompatibleController("test_setting", { key: null }, incompatibleValueFn);
|
||||
settingsGetValueSpy.mockReturnValue("test");
|
||||
expect(controller.incompatibleSetting).toBe(false);
|
||||
expect(incompatibleValueFn).toHaveBeenCalledWith("test");
|
||||
@@ -77,7 +70,7 @@ describe("IncompatibleController", () => {
|
||||
describe("getValueOverride()", () => {
|
||||
it("returns forced value when setting is incompatible", () => {
|
||||
settingsGetValueSpy.mockReturnValue(true);
|
||||
const controller = new IncompatibleController("feature_spotlight" as FeatureSettingKey, { key: null });
|
||||
const controller = new IncompatibleController("test_setting", { key: null });
|
||||
expect(
|
||||
controller.getValueOverride(SettingLevel.ACCOUNT, "$room:server", true, SettingLevel.ACCOUNT),
|
||||
).toEqual({ key: null });
|
||||
@@ -85,7 +78,7 @@ describe("IncompatibleController", () => {
|
||||
|
||||
it("returns null when setting is not incompatible", () => {
|
||||
settingsGetValueSpy.mockReturnValue(false);
|
||||
const controller = new IncompatibleController("feature_spotlight" as FeatureSettingKey, { key: null });
|
||||
const controller = new IncompatibleController("test_setting", { key: null });
|
||||
expect(
|
||||
controller.getValueOverride(SettingLevel.ACCOUNT, "$room:server", true, SettingLevel.ACCOUNT),
|
||||
).toEqual(null);
|
||||
|
||||
Reference in New Issue
Block a user