From 5f74c274bb386b3229115ba16cd535ec6333a465 Mon Sep 17 00:00:00 2001 From: Markus Tacker Date: Mon, 20 Mar 2023 23:54:57 +0100 Subject: [PATCH] fix: migrate tsconfig.json --- agps/deviceRequestHandler.ts | 6 +- agps/getCache.ts | 2 +- cdk/helper/lambdas/findDependencies.ts | 2 +- cellGeolocation/addCellToCacheIfNotExists.ts | 2 +- cellGeolocation/geolocateFromCache.ts | 2 +- .../create-and-provision-device-cert.ts | 2 +- cli/jitp/registerCA.ts | 2 +- feature-runner/steps/asset-tracker.ts | 6 +- feature-runner/steps/httpApiMock.ts | 4 +- feature-runner/steps/timestream.ts | 4 +- geolocation/queueJob.ts | 2 +- historicalData/storeRecordsInTimeseries.ts | 2 +- networkSurveyGeolocation/geolocateSurvey.ts | 2 +- .../httpApi/locateSurvey.ts | 2 +- package-lock.json | 55 +++++++++---------- package.json | 3 +- pgps/deviceRequestHandler.ts | 6 +- pgps/getCache.ts | 2 +- third-party/nrfcloud.com/agps.ts | 4 +- third-party/nrfcloud.com/apiclient.ts | 4 +- .../nrfcloud.com/networksurveygeolocation.ts | 7 ++- third-party/nrfcloud.com/pgps.ts | 2 +- tsconfig.json | 2 +- util/settings.ts | 2 +- 24 files changed, 66 insertions(+), 61 deletions(-) diff --git a/agps/deviceRequestHandler.ts b/agps/deviceRequestHandler.ts index 1f452d2ec..d141848f5 100644 --- a/agps/deviceRequestHandler.ts +++ b/agps/deviceRequestHandler.ts @@ -5,16 +5,16 @@ import { } from '@aws-sdk/client-iot-data-plane' import { SFNClient, StartExecutionCommand } from '@aws-sdk/client-sfn' import { - SendMessageBatchCommand, - SendMessageBatchRequestEntry, SQSClient, + SendMessageBatchCommand, + type SendMessageBatchRequestEntry, } from '@aws-sdk/client-sqs' import type { Static } from '@sinclair/typebox' import type { SQSEvent, SQSMessageAttributes } from 'aws-lambda' import { randomUUID } from 'node:crypto' import { fromEnv } from '../util/fromEnv.js' import { cacheKey } from './cacheKey.js' -import { AGPSDataCache, getCache } from './getCache.js' +import { getCache, type AGPSDataCache } from './getCache.js' import type { agpsRequestSchema } from './types.js' const { diff --git a/agps/getCache.ts b/agps/getCache.ts index 73e7849d1..e1281aa87 100644 --- a/agps/getCache.ts +++ b/agps/getCache.ts @@ -1,7 +1,7 @@ import { DynamoDBClient, GetItemCommand } from '@aws-sdk/client-dynamodb' import { unmarshall } from '@aws-sdk/util-dynamodb' import type { Static } from '@sinclair/typebox' -import { ErrorInfo, ErrorType } from '../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../api/ErrorInfo.js' import type { agpsRequestSchema } from './types.js' export type AGPSDataCache = Static & { diff --git a/cdk/helper/lambdas/findDependencies.ts b/cdk/helper/lambdas/findDependencies.ts index 9137a2e48..8836b2eff 100644 --- a/cdk/helper/lambdas/findDependencies.ts +++ b/cdk/helper/lambdas/findDependencies.ts @@ -1,6 +1,6 @@ import { readFileSync, statSync } from 'node:fs' import path from 'node:path' -import ts, { ImportDeclaration, StringLiteral } from 'typescript' +import ts, { type ImportDeclaration, type StringLiteral } from 'typescript' /** * Resolve project-level dependencies for the given file using TypeScript compiler API diff --git a/cellGeolocation/addCellToCacheIfNotExists.ts b/cellGeolocation/addCellToCacheIfNotExists.ts index 04159db7a..21b9b0066 100644 --- a/cellGeolocation/addCellToCacheIfNotExists.ts +++ b/cellGeolocation/addCellToCacheIfNotExists.ts @@ -1,6 +1,6 @@ import { DynamoDBClient, PutItemCommand } from '@aws-sdk/client-dynamodb' import { cellId } from '@nordicsemiconductor/cell-geolocation-helpers' -import { ErrorInfo, ErrorType } from '../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../api/ErrorInfo.js' import type { Cell } from '../geolocation/Cell.js' import type { Location } from '../geolocation/Location.js' import { fromDeviceLocations } from './cellGeolocationFromDeviceLocations.js' diff --git a/cellGeolocation/geolocateFromCache.ts b/cellGeolocation/geolocateFromCache.ts index 1fef3a887..e60dcaec3 100644 --- a/cellGeolocation/geolocateFromCache.ts +++ b/cellGeolocation/geolocateFromCache.ts @@ -1,6 +1,6 @@ import { DynamoDBClient, GetItemCommand } from '@aws-sdk/client-dynamodb' import { cellId } from '@nordicsemiconductor/cell-geolocation-helpers' -import { ErrorInfo, ErrorType } from '../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../api/ErrorInfo.js' import type { Cell } from '../geolocation/Cell.js' import type { Location } from '../geolocation/Location.js' diff --git a/cli/commands/create-and-provision-device-cert.ts b/cli/commands/create-and-provision-device-cert.ts index 0f94d6689..7d4eec4b3 100644 --- a/cli/commands/create-and-provision-device-cert.ts +++ b/cli/commands/create-and-provision-device-cert.ts @@ -1,10 +1,10 @@ import { atHostHexfile, connect, - Connection, createPrivateKeyAndCSR, flashCertificate, getIMEI, + type Connection, } from '@nordicsemiconductor/firmware-ci-device-helpers' import chalk from 'chalk' import { promises as fs } from 'fs' diff --git a/cli/jitp/registerCA.ts b/cli/jitp/registerCA.ts index 47053b109..8c202d35b 100644 --- a/cli/jitp/registerCA.ts +++ b/cli/jitp/registerCA.ts @@ -6,8 +6,8 @@ import { GetRegistrationCodeCommand, IoTClient, RegisterCACertificateCommand, - Tag, UpdateEventConfigurationsCommand, + type Tag, } from '@aws-sdk/client-iot' import { toObject } from '@nordicsemiconductor/cloudformation-helpers' import { randomUUID } from 'crypto' diff --git a/feature-runner/steps/asset-tracker.ts b/feature-runner/steps/asset-tracker.ts index a132a8fc1..cd71b1906 100644 --- a/feature-runner/steps/asset-tracker.ts +++ b/feature-runner/steps/asset-tracker.ts @@ -1,8 +1,8 @@ import { - InterpolatedStep, regexGroupMatcher, regexMatcher, - StepRunnerFunc, + type InterpolatedStep, + type StepRunnerFunc, } from '@nordicsemiconductor/e2e-bdd-test-runner' import { randomWords } from '@nordicsemiconductor/random-words' import { expect } from 'chai' @@ -13,7 +13,7 @@ import { getCurrentCA } from '../../cli/jitp/currentCA.js' import { deviceFileLocations } from '../../cli/jitp/deviceFileLocations.js' import { awsIotDeviceConnection, - ListenerWithPayload, + type ListenerWithPayload, } from './awsIotDeviceConnection.js' type World = { diff --git a/feature-runner/steps/httpApiMock.ts b/feature-runner/steps/httpApiMock.ts index 0c612baca..1428047ae 100644 --- a/feature-runner/steps/httpApiMock.ts +++ b/feature-runner/steps/httpApiMock.ts @@ -6,9 +6,9 @@ import { QueryCommand, } from '@aws-sdk/client-dynamodb' import { - InterpolatedStep, regexGroupMatcher, - StepRunnerFunc, + type InterpolatedStep, + type StepRunnerFunc, } from '@nordicsemiconductor/e2e-bdd-test-runner' import chai, { expect } from 'chai' import chaiSubset from 'chai-subset' diff --git a/feature-runner/steps/timestream.ts b/feature-runner/steps/timestream.ts index 406d9224b..be1cc5e53 100644 --- a/feature-runner/steps/timestream.ts +++ b/feature-runner/steps/timestream.ts @@ -3,9 +3,9 @@ import { TimestreamQueryClient, } from '@aws-sdk/client-timestream-query' import { - InterpolatedStep, regexMatcher, - StepRunnerFunc, + type InterpolatedStep, + type StepRunnerFunc, } from '@nordicsemiconductor/e2e-bdd-test-runner' import { parseResult } from '@nordicsemiconductor/timestream-helpers' import type { AssetTrackerWorld } from '../run-features.js' diff --git a/geolocation/queueJob.ts b/geolocation/queueJob.ts index cbdf84120..d749e35c3 100644 --- a/geolocation/queueJob.ts +++ b/geolocation/queueJob.ts @@ -1,5 +1,5 @@ import { SendMessageCommand, SQSClient } from '@aws-sdk/client-sqs' -import { ErrorInfo, ErrorType } from '../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../api/ErrorInfo.js' export const queueJob = ({ sqs, QueueUrl }: { sqs: SQSClient; QueueUrl: string }) => diff --git a/historicalData/storeRecordsInTimeseries.ts b/historicalData/storeRecordsInTimeseries.ts index d9e7b78cf..220eb9dac 100644 --- a/historicalData/storeRecordsInTimeseries.ts +++ b/historicalData/storeRecordsInTimeseries.ts @@ -1,7 +1,7 @@ import { TimestreamWriteClient, WriteRecordsCommand, - _Record, + type _Record, } from '@aws-sdk/client-timestream-write' type AWSError = { message: string; code: number } diff --git a/networkSurveyGeolocation/geolocateSurvey.ts b/networkSurveyGeolocation/geolocateSurvey.ts index e84629dac..fb59f32bf 100644 --- a/networkSurveyGeolocation/geolocateSurvey.ts +++ b/networkSurveyGeolocation/geolocateSurvey.ts @@ -1,6 +1,6 @@ import { DynamoDBClient, GetItemCommand } from '@aws-sdk/client-dynamodb' import { unmarshall } from '@aws-sdk/util-dynamodb' -import { ErrorInfo, ErrorType } from '../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../api/ErrorInfo.js' import type { Location } from '../geolocation/Location.js' export type Survey = { diff --git a/networkSurveyGeolocation/httpApi/locateSurvey.ts b/networkSurveyGeolocation/httpApi/locateSurvey.ts index 06c68458b..812068945 100644 --- a/networkSurveyGeolocation/httpApi/locateSurvey.ts +++ b/networkSurveyGeolocation/httpApi/locateSurvey.ts @@ -9,7 +9,7 @@ import type { import { ErrorType, toStatusCode } from '../../api/ErrorInfo.js' import { res } from '../../api/res.js' import { fromEnv } from '../../util/fromEnv.js' -import { geolocateSurvey, Survey } from '../geolocateSurvey.js' +import { geolocateSurvey, type Survey } from '../geolocateSurvey.js' const inputSchema = Type.Object( { diff --git a/package-lock.json b/package-lock.json index 86d542393..f569a4a4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,6 +70,7 @@ "nock": "13.3.0", "octokit-auth-netrc": "2.1.0", "tsx": "3.12.5", + "typescript": "5.0.2", "yazl": "2.5.1" }, "engines": { @@ -15448,6 +15449,19 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/@commitlint/load/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@commitlint/message": { "version": "17.4.2", "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.4.2.tgz", @@ -16921,19 +16935,6 @@ "npm": ">=9" } }, - "node_modules/@nordicsemiconductor/asset-tracker-cloud-code-style/node_modules/typescript": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=12.20" - } - }, "node_modules/@nordicsemiconductor/asset-tracker-cloud-docs": { "version": "28.1.3", "resolved": "https://registry.npmjs.org/@nordicsemiconductor/asset-tracker-cloud-docs/-/asset-tracker-cloud-docs-28.1.3.tgz", @@ -26163,16 +26164,16 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", + "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=12.20" } }, "node_modules/ultron": { @@ -39218,6 +39219,12 @@ "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } + }, + "typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true } } }, @@ -40339,14 +40346,6 @@ "prettier": "2.8.5", "prettier-plugin-organize-imports": "3.2.2", "typescript": "5.0.2" - }, - "dependencies": { - "typescript": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", - "dev": true - } } }, "@nordicsemiconductor/asset-tracker-cloud-docs": { @@ -46717,9 +46716,9 @@ "dev": true }, "typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", + "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", "dev": true }, "ultron": { diff --git a/package.json b/package.json index 159c92212..eb02a7203 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "jest --detectOpenHandles --forceExit", "test:e2e": "node --unhandled-rejections=strict --loader tsx feature-runner/run-features.ts ./features --print-results --progress", "prepare": "husky install && check-node-version --package", - "prepublish": "npx swc -d dist ./cli npx swc -d dist ./features" + "prepublishOnly": "npx swc -d dist ./cli npx swc -d dist ./features" }, "repository": { "type": "git", @@ -92,6 +92,7 @@ "nock": "13.3.0", "octokit-auth-netrc": "2.1.0", "tsx": "3.12.5", + "typescript": "5.0.2", "yazl": "2.5.1" }, "lint-staged": { diff --git a/pgps/deviceRequestHandler.ts b/pgps/deviceRequestHandler.ts index 3f9e58175..7fc8ca492 100644 --- a/pgps/deviceRequestHandler.ts +++ b/pgps/deviceRequestHandler.ts @@ -5,9 +5,9 @@ import { } from '@aws-sdk/client-iot-data-plane' import { SFNClient, StartExecutionCommand } from '@aws-sdk/client-sfn' import { - SendMessageBatchCommand, - SendMessageBatchRequestEntry, SQSClient, + SendMessageBatchCommand, + type SendMessageBatchRequestEntry, } from '@aws-sdk/client-sqs' import type { Static } from '@sinclair/typebox' import type { SQSEvent, SQSMessageAttributes } from 'aws-lambda' @@ -21,7 +21,7 @@ import { defaultNumberOfPredictions, defaultTimeOfDay, } from './cacheKey.js' -import { getCache, PGPSDataCache } from './getCache.js' +import { getCache, type PGPSDataCache } from './getCache.js' import { gpsDay } from './gpsTime.js' import type { pgpsRequestSchema } from './types.js' diff --git a/pgps/getCache.ts b/pgps/getCache.ts index f30c29f8f..b9de5a68b 100644 --- a/pgps/getCache.ts +++ b/pgps/getCache.ts @@ -2,7 +2,7 @@ import { DynamoDBClient, GetItemCommand } from '@aws-sdk/client-dynamodb' import { unmarshall } from '@aws-sdk/util-dynamodb' import type { Static } from '@sinclair/typebox' import { URL } from 'url' -import { ErrorInfo, ErrorType } from '../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../api/ErrorInfo.js' import type { pgpsRequestSchema } from './types.js' export type PGPSDataCache = Static & { diff --git a/third-party/nrfcloud.com/agps.ts b/third-party/nrfcloud.com/agps.ts index 440b4aa21..6faea6e38 100644 --- a/third-party/nrfcloud.com/agps.ts +++ b/third-party/nrfcloud.com/agps.ts @@ -1,9 +1,9 @@ import { SSMClient } from '@aws-sdk/client-ssm' import { validateWithType } from '@nordicsemiconductor/asset-tracker-cloud-docs/protocol' import { verify } from '@nordicsemiconductor/nrfcloud-location-services-tests' -import { Static, Type } from '@sinclair/typebox' +import { Type, type Static } from '@sinclair/typebox' import { URL } from 'url' -import { agpsRequestSchema, AGPSType } from '../../agps/types.js' +import { AGPSType, agpsRequestSchema } from '../../agps/types.js' import type { ErrorInfo } from '../../api/ErrorInfo.js' import { fromEnv } from '../../util/fromEnv.js' import { apiClient } from './apiclient.js' diff --git a/third-party/nrfcloud.com/apiclient.ts b/third-party/nrfcloud.com/apiclient.ts index ecbbb4e73..6a797107a 100644 --- a/third-party/nrfcloud.com/apiclient.ts +++ b/third-party/nrfcloud.com/apiclient.ts @@ -1,9 +1,9 @@ import type { Static, TObject, TProperties } from '@sinclair/typebox' import Ajv from 'ajv' import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http' -import { request as nodeRequest, RequestOptions } from 'https' +import { request as nodeRequest, type RequestOptions } from 'https' import type { URL } from 'url' -import { ErrorInfo, ErrorType } from '../../api/ErrorInfo.js' +import { ErrorType, type ErrorInfo } from '../../api/ErrorInfo.js' import { createToken } from './createToken.js' const ajv = new Ajv() diff --git a/third-party/nrfcloud.com/networksurveygeolocation.ts b/third-party/nrfcloud.com/networksurveygeolocation.ts index ec5707f84..44e2856fe 100644 --- a/third-party/nrfcloud.com/networksurveygeolocation.ts +++ b/third-party/nrfcloud.com/networksurveygeolocation.ts @@ -4,7 +4,12 @@ import { validateWithType, WiFiSiteSurvey, } from '@nordicsemiconductor/asset-tracker-cloud-docs/protocol' -import { Static, TObject, TProperties, Type } from '@sinclair/typebox' +import { + Type, + type Static, + type TObject, + type TProperties, +} from '@sinclair/typebox' import { URL } from 'url' import type { MaybeLocation } from '../../geolocation/types.js' import { expandMac } from '../../networkSurveyGeolocation/expandMac.js' diff --git a/third-party/nrfcloud.com/pgps.ts b/third-party/nrfcloud.com/pgps.ts index 9e8bd130a..3e67e6d3a 100644 --- a/third-party/nrfcloud.com/pgps.ts +++ b/third-party/nrfcloud.com/pgps.ts @@ -1,6 +1,6 @@ import { SSMClient } from '@aws-sdk/client-ssm' import { validateWithType } from '@nordicsemiconductor/asset-tracker-cloud-docs/protocol' -import { Static, Type } from '@sinclair/typebox' +import { Type, type Static } from '@sinclair/typebox' import { URL } from 'url' import { defaultInterval, diff --git a/tsconfig.json b/tsconfig.json index eb1e29fdc..8d9ae7df6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noEmit": true, - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "skipLibCheck": true } } diff --git a/util/settings.ts b/util/settings.ts index 887df9478..f7b60934a 100644 --- a/util/settings.ts +++ b/util/settings.ts @@ -1,9 +1,9 @@ import { DeleteParameterCommand, GetParametersByPathCommand, - Parameter, PutParameterCommand, SSMClient, + type Parameter, } from '@aws-sdk/client-ssm' import { paginate } from './paginate.js'