Skip to content

Commit 2f123d4

Browse files
Merge pull request #1313 from opencomponents/remove-some-anys
remove some any types
2 parents 2dda18f + 8c32682 commit 2f123d4

File tree

14 files changed

+30
-31
lines changed

14 files changed

+30
-31
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@
108108
"oc-client-browser": "1.5.9",
109109
"oc-empty-response-handler": "1.0.2",
110110
"oc-get-unix-utc-timestamp": "1.0.6",
111-
"oc-s3-storage-adapter": "2.0.0",
112-
"oc-storage-adapters-utils": "2.0.0",
111+
"oc-s3-storage-adapter": "2.1.1",
112+
"oc-storage-adapters-utils": "2.0.2",
113113
"oc-template-es6": "1.0.7",
114114
"oc-template-es6-compiler": "2.1.0",
115115
"oc-template-handlebars": "6.0.25",

src/cli/domain/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default function registry(opts: RegistryOptions = {}) {
123123
) {
124124
errMsg = parsedError.error;
125125
} else {
126-
errMsg = parsedError as any;
126+
errMsg = parsedError;
127127
}
128128

129129
throw errMsg;

src/cli/facade/dev.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,11 @@ const dev = ({ local, logger }: { logger: Logger; local: Local }) =>
202202

203203
return registry;
204204
} catch (err: any) {
205-
if (err.code === 'EADDRINUSE') {
206-
// eslint-disable-next-line no-ex-assign
207-
err = cliErrors.PORT_IS_BUSY(port) as any;
208-
}
205+
const error =
206+
err.code === 'EADDRINUSE' ? cliErrors.PORT_IS_BUSY(port) : err;
209207

210-
logger.err(String(err));
211-
throw err;
208+
logger.err(String(error));
209+
throw error;
212210
}
213211
}
214212
);

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,6 @@ const argv = cli
137137
.version()
138138
.wrap(cli.terminalWidth()).argv;
139139

140-
if ((argv as any)._.length === 0) {
140+
if ((argv as Awaited<typeof argv>)._.length === 0) {
141141
cli.showHelp();
142142
}

src/registry/app-start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default async function appStart(
6161
logger.log(colors.green('Component published.'));
6262
} catch (err) {
6363
logger.log(
64-
colors.red(`Component not published: ${(err as any).message}`)
64+
colors.red(`Component not published: ${(err as Error).message}`)
6565
);
6666
throw err;
6767
}

src/registry/domain/events-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ type Subscription<T = any> = (data: T) => void;
55
let subscriptions: Record<string, Array<Subscription>> = {};
66

77
export interface RequestData {
8-
body: any;
8+
body: unknown;
99
duration: number;
1010
headers: IncomingHttpHeaders;
1111
method: string;
1212
path: string;
1313
relativeUrl: string;
14-
query: Record<string, any>;
14+
query: Record<string, unknown>;
1515
url: string;
1616
statusCode: number;
1717
errorDetails?: string;

src/registry/domain/extract-package.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import path from 'path';
22
import targz from 'targz';
33
import { promisify } from 'util';
4-
import { PackageJson } from 'type-fest';
54

65
import getPackageJsonFromTempDir from './get-package-json-from-temp-dir';
6+
import { Component } from '../../types';
77

88
export default async function extractPackage(
99
files:
@@ -14,9 +14,9 @@ export default async function extractPackage(
1414
tarExtractMode: number
1515
): Promise<{
1616
outputFolder: string;
17-
packageJson: PackageJson;
17+
packageJson: Component;
1818
}> {
19-
const packageFile: Express.Multer.File = (files as any)[0];
19+
const packageFile = (files as Express.Multer.File[])[0];
2020
const packagePath = path.resolve(packageFile.path);
2121
const packageUntarOutput = path.resolve(
2222
packageFile.path,
@@ -40,6 +40,6 @@ export default async function extractPackage(
4040

4141
return {
4242
outputFolder: packageOutput,
43-
packageJson: packageJson
43+
packageJson
4444
};
4545
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import fs from 'fs-extra';
22
import path from 'path';
3-
import { PackageJson } from 'type-fest';
3+
import { Component } from '../../types';
44

55
export default function getPackageJsonFromTempDir(
66
tempDirPath: string
7-
): Promise<PackageJson> {
7+
): Promise<Component> {
88
return fs.readJson(path.join(tempDirPath, 'package.json'));
99
}

src/registry/domain/repository.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,18 @@ export default function repository(conf: Config) {
274274

275275
getTemplatesInfo: (): TemplateInfo[] => templatesInfo,
276276
getTemplate: (type: string) => templatesHash[type],
277-
async init(): Promise<ComponentsDetails> {
277+
async init(): Promise<ComponentsDetails | undefined> {
278278
if (conf.local) {
279279
// when in local this won't get called
280-
return 'ok' as any;
280+
return;
281281
}
282282

283283
const componentsList = await componentsCache.load();
284284

285285
return componentsDetails.refresh(componentsList);
286286
},
287287
async publishComponent(
288-
pkgDetails: any,
288+
pkgDetails: { outputFolder: string; packageJson: Component },
289289
componentName: string,
290290
componentVersion: string
291291
): Promise<ComponentsDetails> {

src/registry/domain/validators/package-json-validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ValidationResult {
77

88
interface PkgDetails {
99
componentName: string;
10-
packageJson: { name: string };
10+
packageJson: { name?: string };
1111
customValidator: (data: unknown) => ValidationResult | boolean;
1212
}
1313

0 commit comments

Comments
 (0)