Skip to content

Commit

Permalink
Improve type imports by using "import type" where possible
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
joshbwlng committed Feb 4, 2024
1 parent 79f7d61 commit 1405999
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 49 deletions.
8 changes: 4 additions & 4 deletions src/config-loader/config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import type {
} from '../sbvr-api/common-types';

import {
Migration,
Migrations,
type Migration,
type Migrations,
defaultMigrationCategory,
MigrationCategories,
isSyncMigration,
Expand All @@ -30,11 +30,11 @@ import * as permissions from '../sbvr-api/permissions';
import {
getDefaultHandler,
getUploaderMiddlware,
WebResourceHandler,
type WebResourceHandler,
setupUploadHooks,
setupWebresourceHandler,
} from '../webresource-handler';
import { AliasValidNodeType } from '../sbvr-api/translations';
import type { AliasValidNodeType } from '../sbvr-api/translations';

export type SetupFunction = (
app: Express.Application,
Expand Down
8 changes: 4 additions & 4 deletions src/migrator/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ type InitialMigrationStatus = MigrationStatus &
>;

import {
MigrationTuple,
type MigrationTuple,
getExecutedMigrations,
migratorEnv,
lockMigrations,
initMigrationStatus,
readMigrationStatus,
updateMigrationStatus,
RunnableAsyncMigrations,
type RunnableAsyncMigrations,
getRunnableAsyncMigrations,
filterAndSortPendingMigrations,
MigrationStatus,
BaseAsyncMigration,
type MigrationStatus,
type BaseAsyncMigration,
} from './utils';
import { booleanToEnabledString } from '../config-loader/env';

Expand Down
6 changes: 3 additions & 3 deletions src/migrator/sync.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
MigrationTuple,
type MigrationTuple,
MigrationError,
MigrationExecutionResult,
type MigrationExecutionResult,
setExecutedMigrations,
getExecutedMigrations,
lockMigrations,
RunnableMigrations,
type RunnableMigrations,
filterAndSortPendingMigrations,
getRunnableSyncMigrations,
} from './utils';
Expand Down
2 changes: 1 addition & 1 deletion src/odata-metadata/odata-metadata-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
AbstractSqlTable,
} from '@balena/abstract-sql-compiler';

import sbvrTypes, { SbvrType } from '@balena/sbvr-types';
import sbvrTypes, { type SbvrType } from '@balena/sbvr-types';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version }: { version: string } = require('../../package.json');
Expand Down
2 changes: 1 addition & 1 deletion src/passport-pinejs/mount-login-router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as passportPinejs from './passport-pinejs';
import type { Express } from 'express';
import { PinejsSessionStore } from '../pinejs-session-store/pinejs-session-store';
import { setup } from '../config-loader/config-loader';
import type { setup } from '../config-loader/config-loader';

export const mountLoginRouter = async (
configLoader: ReturnType<typeof setup>,
Expand Down
4 changes: 2 additions & 2 deletions src/sbvr-api/abstract-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import _ from 'lodash';
import * as AbstractSQLCompiler from '@balena/abstract-sql-compiler';
import type { BindKey } from '@balena/odata-parser';
import {
ODataBinds,
type ODataBinds,
odataNameToSqlName,
isBindReference,
} from '@balena/odata-to-abstract-sql';
Expand All @@ -12,7 +12,7 @@ import memoize from 'memoizee';
import * as env from '../config-loader/env';
import { BadRequestError, SqlCompilationError } from './errors';
import * as sbvrUtils from './sbvr-utils';
import { ODataRequest } from './uri-parser';
import type { ODataRequest } from './uri-parser';

const getMemoizedCompileRule = memoize(
(engine: AbstractSQLCompiler.Engines) =>
Expand Down
2 changes: 1 addition & 1 deletion src/sbvr-api/common-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { AnyObject, Dictionary } from 'pinejs-client-core';
export type { AnyObject, Dictionary } from 'pinejs-client-core';

type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
export type RequiredField<T, F extends keyof T> = Overwrite<
Expand Down
8 changes: 4 additions & 4 deletions src/sbvr-api/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import _ from 'lodash';
import { settleMapSeries } from './control-flow';
import memoize from 'memoizee';
import {
PinejsClient,
User,
ApiKey,
type PinejsClient,
type User,
type ApiKey,
resolveSynonym,
getAbstractSqlModel,
api,
Response,
type Response,
} from './sbvr-utils';

export interface HookReq {
Expand Down
2 changes: 1 addition & 1 deletion src/sbvr-api/odata-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare module '@balena/abstract-sql-compiler' {
import type { Result, Row } from '../database-layer/db';

import { sqlNameToODataName } from '@balena/odata-to-abstract-sql';
import sbvrTypes, { SbvrType } from '@balena/sbvr-types';
import sbvrTypes, { type SbvrType } from '@balena/sbvr-types';
import _ from 'lodash';
import { resolveNavigationResource, resolveSynonym } from './sbvr-utils';
import { getWebresourceHandler } from '../webresource-handler';
Expand Down
6 changes: 3 additions & 3 deletions src/sbvr-api/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
isBindReference,
type OData2AbstractSQL,
odataNameToSqlName,
ResourceFunction,
type ResourceFunction,
sqlNameToODataName,
} from '@balena/odata-to-abstract-sql';
import * as ODataParser from '@balena/odata-parser';
Expand All @@ -38,7 +38,7 @@ import memoize from 'memoizee';
import * as randomstring from 'randomstring';
import * as env from '../config-loader/env';
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
import { HookReq, addPureHook, addHook } from './hooks';
import { type HookReq, addPureHook, addHook } from './hooks';
import {
BadRequestError,
PermissionError,
Expand All @@ -48,7 +48,7 @@ import {
memoizedGetOData2AbstractSQL,
memoizedParseOdata,
metadataEndpoints,
ODataRequest,
type ODataRequest,
} from './uri-parser';
import memoizeWeak = require('memoizee/weak');

Expand Down
26 changes: 13 additions & 13 deletions src/sbvr-api/sbvr-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare global {

import _ from 'lodash';

import { TypedError } from 'typed-error';
import type { TypedError } from 'typed-error';
import { cachedCompile } from './cached-compile';

type LFModel = any[];
Expand All @@ -25,14 +25,14 @@ import { version as AbstractSQLCompilerVersion } from '@balena/abstract-sql-comp
import * as LF2AbstractSQL from '@balena/lf-to-abstract-sql';

import {
ODataBinds,
type ODataBinds,
odataNameToSqlName,
sqlNameToODataName,
SupportedMethod,
type SupportedMethod,
} from '@balena/odata-to-abstract-sql';
import sbvrTypes from '@balena/sbvr-types';
import deepFreeze = require('deep-freeze');
import { PinejsClientCore, PromiseResultTypes } from 'pinejs-client-core';
import { PinejsClientCore, type PromiseResultTypes } from 'pinejs-client-core';

import { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser';

Expand Down Expand Up @@ -60,20 +60,20 @@ import {
UnauthorizedError,
} from './errors';
import * as uriParser from './uri-parser';
export { ODataRequest } from './uri-parser';
export type { ODataRequest } from './uri-parser';
import {
HookReq,
HookArgs,
type HookReq,
type HookArgs,
rollbackRequestHooks,
getHooks,
runHooks,
InstantiatedHooks,
type InstantiatedHooks,
} from './hooks';
export {
HookReq,
HookArgs,
HookResponse,
Hooks,
type HookReq,
type HookArgs,
type HookResponse,
type Hooks,
addPureHook,
addSideEffectHook,
} from './hooks';
Expand All @@ -97,7 +97,7 @@ import * as odataResponse from './odata-response';
import { env } from '../server-glue/module';
import { translateAbstractSqlModel } from './translations';
import {
MigrationExecutionResult,
type MigrationExecutionResult,
setExecutedMigrations,
} from '../migrator/utils';

Expand Down
4 changes: 2 additions & 2 deletions src/sbvr-api/translations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import {
import type {
AbstractSqlModel,
Relationship,
ReferencedFieldNode,
Expand All @@ -14,7 +14,7 @@ import {
UnknownTypeNodes,
NullNode,
} from '@balena/abstract-sql-compiler';
import { Dictionary } from './common-types';
import type { Dictionary } from './common-types';

export type AliasValidNodeType =
| ReferencedFieldNode
Expand Down
2 changes: 1 addition & 1 deletion src/server-glue/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './sbvr-loader';
import * as dbModule from '../database-layer/db';
import * as configLoader from '../config-loader/config-loader';
import * as migrator from '../migrator/sync';
import * as migratorUtils from '../migrator/utils';
import type * as migratorUtils from '../migrator/utils';

import * as sbvrUtils from '../sbvr-api/sbvr-utils';
import { PINEJS_ADVISORY_LOCK } from '../config-loader/env';
Expand Down
2 changes: 1 addition & 1 deletion src/webresource-handler/handlers/NoopHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WebResourceType as WebResource } from '@balena/sbvr-types';
import { IncomingFile, UploadResponse, WebResourceHandler } from '..';
import type { IncomingFile, UploadResponse, WebResourceHandler } from '..';

export class NoopHandler implements WebResourceHandler {
public async handleFile(resource: IncomingFile): Promise<UploadResponse> {
Expand Down
10 changes: 5 additions & 5 deletions src/webresource-handler/handlers/S3Handler.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
FileSizeExceededError,
IncomingFile,
type IncomingFile,
normalizeHref,
UploadResponse,
type UploadResponse,
WebResourceError,
WebResourceHandler,
type WebResourceHandler,
} from '..';
import {
S3Client,
S3ClientConfig,
type S3ClientConfig,
DeleteObjectCommand,
PutObjectCommandInput,
type PutObjectCommandInput,
GetObjectCommand,
} from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
Expand Down
2 changes: 1 addition & 1 deletion src/webresource-handler/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as Express from 'express';
import busboy from 'busboy';
import * as stream from 'stream';
import type * as stream from 'node:stream';
import * as uriParser from '../sbvr-api/uri-parser';
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
import type { HookArgs } from '../sbvr-api/hooks';
Expand Down
2 changes: 1 addition & 1 deletion test/03-async-migrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assert, expect } from 'chai';
import { setTimeout } from 'timers';
import { dbModule } from '../src/server-glue/module';
import { testInit, testDeInit, testLocalServer } from './lib/test-init';
import { MigrationStatus } from '../src/migrator/utils';
import type { MigrationStatus } from '../src/migrator/utils';

const fixturesBasePath = __dirname + '/fixtures/03-async-migrator/';

Expand Down
2 changes: 1 addition & 1 deletion test/04-translations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const hooksPath = __dirname + '/fixtures/04-translations/translations/hooks.js';
import { testInit, testDeInit, testLocalServer } from './lib/test-init';
import { faker } from '@faker-js/faker';
import { expect } from 'chai';
import { AnyObject } from 'pinejs-client-core';
import type { AnyObject } from 'pinejs-client-core';

import { PineTest } from 'pinejs-client-supertest';

Expand Down

0 comments on commit 1405999

Please sign in to comment.