Skip to content

Commit 10ebf46

Browse files
committed
refactor: move ambient const enums into real modules
TypeScript inlines `const enum` values at compile time and erases the import, so declaring them in .d.ts files worked only because tsc has whole-program type information. Any file-local transpiler (esbuild, swc, tsx, vite, bun) cannot inline them and fails to resolve the import, which blocks running the sources without a full tsc pass. The 12 ambient const enums now live in real modules: - 5 from lib/common/declarations.d.ts -> lib/common/enums.ts - BuildNames -> lib/constants.ts, next to the other build-related enums - detached-process-enums, system-warnings and google-analytics-custom-dimensions -> .d.ts renamed to .ts; they held nothing but enums - SpecialKeys -> key-commands.d.ts renamed to .ts, which already exported everything, so importers are unchanged The four global files had no imports, making their enums globally visible; consumers now import them explicitly. GoogleAnalyticsCrossClientCustomDimensions is referenced nowhere and was dropped rather than converted into a dead runtime module. Renaming key-commands to .ts surfaced two interface methods whose missing return types an ambient context had allowed; both implementations return nothing, so they are annotated void.
1 parent 1084bc7 commit 10ebf46

38 files changed

Lines changed: 461 additions & 448 deletions

lib/commands/build.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
import { IPlatformsDataService } from "../definitions/platform";
1414
import { IBuildController, IBuildDataService } from "../definitions/build";
1515
import { IMigrateController } from "../definitions/migrate";
16-
import { IErrors, OptionType } from "../common/declarations";
16+
import { IErrors } from "../common/declarations";
17+
import { OptionType } from "../common/enums";
1718
import { ICommandParameter, ICommand } from "../common/definitions/commands";
1819
import { injector } from "../common/yok";
1920

lib/commands/debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ICleanupService } from "../definitions/cleanup-service";
1717
import { IInjector } from "../common/definitions/yok";
1818
import { injector } from "../common/yok";
1919
import * as _ from "lodash";
20+
import { SystemWarningsSeverity } from "../definitions/system-warnings";
2021

2122
export class DebugPlatformCommand
2223
extends ValidatePlatformCommandBase

lib/commands/deploy.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import { IPlatformValidationService, IOptions } from "../declarations";
1010
import { IPlatformsDataService } from "../definitions/platform";
1111
import { IMigrateController } from "../definitions/migrate";
1212
import { ICommand, ICommandParameter } from "../common/definitions/commands";
13-
import { OptionType, IErrors } from "../common/declarations";
13+
import { IErrors } from "../common/declarations";
14+
import { OptionType } from "../common/enums";
1415
import { injector } from "../common/yok";
1516

1617
export class DeployOnDeviceCommand
1718
extends ValidatePlatformCommandBase
18-
implements ICommand {
19+
implements ICommand
20+
{
1921
public allowedParameters: ICommandParameter[] = [];
2022

2123
public dashedOptions = {
@@ -36,13 +38,13 @@ export class DeployOnDeviceCommand
3638
private $mobileHelper: Mobile.IMobileHelper,
3739
$platformsDataService: IPlatformsDataService,
3840
private $deployCommandHelper: DeployCommandHelper,
39-
private $migrateController: IMigrateController
41+
private $migrateController: IMigrateController,
4042
) {
4143
super(
4244
$options,
4345
$platformsDataService,
4446
$platformValidationService,
45-
$projectData
47+
$projectData,
4648
);
4749
this.$projectData.initializeProjectData();
4850
}

lib/commands/prepare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IOptions, IPlatformValidationService } from "../declarations";
66
import { IPlatformsDataService } from "../definitions/platform";
77
import { IMigrateController } from "../definitions/migrate";
88
import { ICommand, ICommandParameter } from "../common/definitions/commands";
9-
import { OptionType } from "../common/declarations";
9+
import { OptionType } from "../common/enums";
1010
import { injector } from "../common/yok";
1111

1212
export class PrepareCommand

lib/commands/test.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import { IPlatformEnvironmentRequirements } from "../definitions/platform";
99
import { IMigrateController } from "../definitions/migrate";
1010
import { ICommandParameter, ICommand } from "../common/definitions/commands";
1111
import {
12-
OptionType,
1312
IAnalyticsService,
1413
IErrors,
1514
IDictionary,
16-
ErrorCodes,
1715
} from "../common/declarations";
16+
import { ErrorCodes, OptionType } from "../common/enums";
1817
import { ICleanupService } from "../definitions/cleanup-service";
1918
import { injector } from "../common/yok";
2019

@@ -47,19 +46,18 @@ abstract class TestCommandBase {
4746
sdk: this.$options.sdk,
4847
});
4948

50-
const selectedDeviceForDebug = await this.$devicesService.pickSingleDevice(
51-
{
49+
const selectedDeviceForDebug =
50+
await this.$devicesService.pickSingleDevice({
5251
onlyEmulators: this.$options.emulator,
5352
onlyDevices: this.$options.forDevice,
5453
deviceId: this.$options.device,
55-
}
56-
);
54+
});
5755
devices = [selectedDeviceForDebug];
5856
// const debugData = this.getDebugData(platform, projectData, deployOptions, { device: selectedDeviceForDebug.deviceInfo.identifier });
5957
// await this.$debugService.debug(debugData, this.$options);
6058
} else {
6159
devices = await this.$liveSyncCommandHelper.getDeviceInstances(
62-
this.platform
60+
this.platform,
6361
);
6462
}
6563

@@ -69,25 +67,26 @@ abstract class TestCommandBase {
6967
this.$options.env.unitTesting = true;
7068

7169
const liveSyncInfo = this.$liveSyncCommandHelper.getLiveSyncData(
72-
this.$projectData.projectDir
70+
this.$projectData.projectDir,
7371
);
7472

7573
const deviceDebugMap: IDictionary<boolean> = {};
7674
devices.forEach(
7775
(device) =>
78-
(deviceDebugMap[device.deviceInfo.identifier] = this.$options.debugBrk)
76+
(deviceDebugMap[device.deviceInfo.identifier] = this.$options.debugBrk),
7977
);
8078

81-
const deviceDescriptors = await this.$liveSyncCommandHelper.createDeviceDescriptors(
82-
devices,
83-
this.platform,
84-
<any>{ deviceDebugMap }
85-
);
79+
const deviceDescriptors =
80+
await this.$liveSyncCommandHelper.createDeviceDescriptors(
81+
devices,
82+
this.platform,
83+
<any>{ deviceDebugMap },
84+
);
8685

8786
await this.$testExecutionService.startKarmaServer(
8887
this.platform,
8988
liveSyncInfo,
90-
deviceDescriptors
89+
deviceDescriptors,
9190
);
9291
// if we got here, it means karma exited with exit code 0 (success)
9392
process.exit(0);
@@ -100,7 +99,7 @@ abstract class TestCommandBase {
10099
// because the Runtime does not watch for the `/data/local/tmp<appId>-livesync-in-progress` file deletion.
101100
// The App is closing itself after each test execution and the bug will be reproducible on each LiveSync.
102101
this.$errors.fail(
103-
"The `--hmr` option is not supported for this command."
102+
"The `--hmr` option is not supported for this command.",
104103
);
105104
}
106105

@@ -112,23 +111,21 @@ abstract class TestCommandBase {
112111

113112
this.$projectData.initializeProjectData();
114113
this.$analyticsService.setShouldDispose(
115-
this.$options.justlaunch || !this.$options.watch
114+
this.$options.justlaunch || !this.$options.watch,
116115
);
117116
this.$cleanupService.setShouldDispose(
118-
this.$options.justlaunch || !this.$options.watch
117+
this.$options.justlaunch || !this.$options.watch,
119118
);
120119

121-
const output = await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(
122-
{
120+
const output =
121+
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({
123122
platform: this.platform,
124123
projectDir: this.$projectData.projectDir,
125124
options: this.$options,
126-
}
127-
);
125+
});
128126

129-
const canStartKarmaServer = await this.$testExecutionService.canStartKarmaServer(
130-
this.$projectData
131-
);
127+
const canStartKarmaServer =
128+
await this.$testExecutionService.canStartKarmaServer(this.$projectData);
132129
if (!canStartKarmaServer) {
133130
this.$errors.fail({
134131
formatStr:
@@ -154,7 +151,7 @@ class TestAndroidCommand extends TestCommandBase implements ICommand {
154151
protected $cleanupService: ICleanupService,
155152
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
156153
protected $devicesService: Mobile.IDevicesService,
157-
protected $migrateController: IMigrateController
154+
protected $migrateController: IMigrateController,
158155
) {
159156
super();
160157
}
@@ -195,7 +192,7 @@ class TestIosCommand extends TestCommandBase implements ICommand {
195192
protected $cleanupService: ICleanupService,
196193
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
197194
protected $devicesService: Mobile.IDevicesService,
198-
protected $migrateController: IMigrateController
195+
protected $migrateController: IMigrateController,
199196
) {
200197
super();
201198
}

0 commit comments

Comments
 (0)