Browse Source
Task/improve type safety for unassigned variables in API (#7755 )
* fix(api): resolve type errors in src/app
* fix(api): resolve type errors in src/services
* fix(api): update log level type
* fix(api): reformat files
pull/7757/head^2
Kenrick Tandrian
1 week ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with
32 additions and
27 deletions
apps/api/src/app/activities/activities.controller.ts
apps/api/src/app/activities/activities.service.ts
apps/api/src/app/admin/admin.controller.ts
apps/api/src/app/admin/admin.service.ts
apps/api/src/app/endpoints/mcp/mcp.controller.ts
apps/api/src/app/export/export.controller.ts
apps/api/src/app/import/import.service.ts
apps/api/src/app/info/info.service.ts
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
apps/api/src/app/portfolio/portfolio.service.ts
apps/api/src/main.ts
apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts
apps/api/src/services/fetch/fetch.service.ts
apps/api/src/services/prisma/prisma.service.ts
apps/api/src/services/queues/data-gathering/data-gathering.processor.ts
@ -66,8 +66,8 @@ export class ActivitiesController {
tags
} : ActivitiesFilterDto
) : Promise < number > {
let endDate : Date ;
let startDate : Date ;
let endDate : Date | undefined ;
let startDate : Date | undefined ;
if ( range ) {
( { endDate , startDate } = getIntervalFromDateRange ( {
@ -139,8 +139,8 @@ export class ActivitiesController {
take
} : GetActivitiesDto
) : Promise < ActivitiesResponse > {
let endDate : Date ;
let startDate : Date ;
let endDate : Date | undefined ;
let startDate : Date | undefined ;
if ( range ) {
( { endDate , startDate } = getIntervalFromDateRange ( {
@ -193,7 +193,8 @@ export class ActivitiesService {
userId : data.userId
} ) ;
let account : Prisma.AccountCreateNestedOneWithoutActivitiesInput ;
let account :
Prisma . AccountCreateNestedOneWithoutActivitiesInput | undefined ;
if ( data . accountId ) {
account = {
@ -186,7 +186,7 @@ export class AdminController {
@Param ( 'symbol' ) symbol : string ,
@Query ( 'range' ) dateRange : DateRange
) : Promise < void > {
let date : Date ;
let date : Date | undefined ;
if ( dateRange ) {
const { startDate } = getIntervalFromDateRange ( { dateRange } ) ;
@ -659,7 +659,7 @@ export class AdminService {
}
private async countUsersWithAnalytics() {
let where : Prisma.UserWhereInput ;
let where : Prisma.UserWhereInput | undefined ;
if ( this . configurationService . get ( 'ENABLE_FEATURE_SUBSCRIPTION' ) ) {
where = {
@ -99,8 +99,8 @@ export class GhostfolioMcpController {
take
} : z . infer < typeof GET_ACTIVITIES_PARAMETERS >
) {
let endDate : Date ;
let startDate : Date ;
let endDate : Date | undefined ;
let startDate : Date | undefined ;
if ( range ) {
( { endDate , startDate } = getIntervalFromDateRange ( {
@ -45,8 +45,8 @@ export class ExportController {
tags
} : GetExportDto
) : Promise < ExportResponse > {
let endDate : Date ;
let startDate : Date ;
let endDate : Date | undefined ;
let startDate : Date | undefined ;
if ( range ) {
( { endDate , startDate } = getIntervalFromDateRange ( {
@ -395,7 +395,7 @@ export class ImportService {
if ( ! isDryRun ) {
const existingTag = await this . tagService . getTag ( { id : tag.id } ) ;
let oldTagId : string ;
let oldTagId : string | undefined ;
if ( existingTag ) {
oldTagId = tag . id ;
@ -509,7 +509,7 @@ export class ImportService {
'tags'
] ) ;
let oldAccountId : string ;
let oldAccountId : string | undefined ;
const platformId =
platformIdMapping [ account . platformId ] ? ? account . platformId ;
@ -596,7 +596,7 @@ export class ImportService {
] ) ;
for ( const assetProfileWithMarketData of assetProfilesWithMarketDataDto ) {
let assetProfileToCreate : Prisma.SymbolProfileCreateInput ;
let assetProfileToCreate : Prisma.SymbolProfileCreateInput | undefined ;
let symbol = assetProfileWithMarketData . symbol ;
// Check if there is any existing asset profile
@ -47,8 +47,9 @@ export class InfoService {
public async get ( ) : Promise < InfoItem > {
const info : Partial < InfoItem > = { } ;
let isReadOnlyMode : boolean ;
let latestFearAndGreedStocksMarketDataPromise : Promise < MarketData > ;
let isReadOnlyMode : boolean | undefined ;
let latestFearAndGreedStocksMarketDataPromise :
Promise < MarketData > | undefined ;
const globalPermissions : string [ ] = [ ] ;
@ -1166,7 +1166,7 @@ export abstract class PortfolioCalculator {
private async initialize ( attempt = 1 ) {
const startTimeTotal = performance . now ( ) ;
let cachedPortfolioSnapshot : PortfolioSnapshot ;
let cachedPortfolioSnapshot : PortfolioSnapshot | undefined ;
let isCachedPortfolioSnapshotExpired = false ;
const portfolioSnapshotKey = this . redisCacheService . getPortfolioSnapshotKey (
{
@ -569,7 +569,10 @@ export class PortfolioService {
} ) ;
}
let streaks : PortfolioInvestmentsResponse [ 'streaks' ] ;
let streaks : PortfolioInvestmentsResponse [ 'streaks' ] = {
currentStreak : 0 ,
longestStreak : 0
} ;
if ( savingsRate ) {
streaks = this . getStreaks ( {
@ -853,7 +856,7 @@ export class PortfolioService {
( { markets , marketsAdvanced } = this . getAggregatedMarkets ( holdings ) ) ;
}
let summary : PortfolioSummary ;
let summary : PortfolioSummary | undefined ;
if ( withSummary ) {
summary = await this . getSummary ( {
@ -46,7 +46,7 @@ async function bootstrap() {
const configApp = await NestFactory . create ( AppModule ) ;
const configService = configApp . get < ConfigService > ( ConfigService ) ;
let customLogLevels : LogLevel [ ] ;
let customLogLevels : LogLevel [ ] | undefined ;
try {
customLogLevels = JSON . parse (
@ -726,11 +726,11 @@ export class FinancialModelingPrepService
}
private parseAssetClass ( profile : any ) : {
assetClass : AssetClass ;
assetSubClass : AssetSubClass ;
assetClass : AssetClass | undefined ;
assetSubClass : AssetSubClass | undefined ;
} {
let assetClass : AssetClass ;
let assetSubClass : AssetSubClass ;
let assetClass : AssetClass | undefined ;
let assetSubClass : AssetSubClass | undefined ;
if ( profile ) {
if ( profile . isEtf ) {
@ -156,7 +156,7 @@ export class FetchService implements OnModuleInit {
text
] ;
let rejectedBody : string ;
let rejectedBody : string | undefined ;
for ( const candidate of candidates ) {
if ( typeof candidate !== 'string' ) {
@ -21,7 +21,7 @@ export class PrismaService
connectionString : configService.get < string > ( 'DATABASE_URL' )
} ) ;
let customLogLevels : LogLevel [ ] ;
let customLogLevels : LogLevel [ ] | undefined ;
try {
customLogLevels = JSON . parse (
@ -119,7 +119,7 @@ export class DataGatheringProcessor {
const data : Prisma.MarketDataUpdateInput [ ] = [ ] ;
const startOfUtcDateOfToday = getStartOfUtcDate ( new Date ( ) ) ;
let lastMarketPrice : number ;
let lastMarketPrice : number | undefined ;
while ( isBefore ( currentDate , startOfUtcDateOfToday ) ) {
const marketPriceOfDataProvider =