Skip to content

Commit 08a307a

Browse files
committed
refactor typings
1 parent 20622a1 commit 08a307a

File tree

16 files changed

+44
-55
lines changed

16 files changed

+44
-55
lines changed

GhostUI/ClientApp/api/services/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class AuthService extends BaseService {
1616
}
1717

1818
public async login(credentials: ICredentials): Promise<IAuthUser> {
19-
const { data } = await this.$http.post('Login', credentials);
20-
return data as IAuthUser;
19+
const { data } = await this.$http.post<IAuthUser>('Login', credentials);
20+
return data;
2121
}
2222

2323
public async logout(): Promise<any> {

GhostUI/ClientApp/api/services/sample.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ class SampleService extends BaseService {
1616
}
1717

1818
public async getWeatherForecastsAsync(startDateIndex: number): Promise<IWeatherForecast[]> {
19-
const { data } = await this.$http.get('GetWeatherForecasts', { params: { startDateIndex: startDateIndex } });
20-
return data as IWeatherForecast[];
19+
const { data } = await this.$http.get<IWeatherForecast[]>(
20+
'GetWeatherForecasts',
21+
{ params: { startDateIndex: startDateIndex } }
22+
);
23+
24+
return data;
2125
}
2226
}
2327

GhostUI/ClientApp/api/services/signalR.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SignalRService {
3636

3737
setTimeout(() => {
3838
this._hubConnection.start().catch((error) => {
39-
console.error(error.toString());
39+
console.error(String(error));
4040
});
4141
}, _signalrConfig.CONNECTION_DELAY);
4242
}

GhostUI/ClientApp/assets/style/scss/base/generic.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ code {
2424
font-size: 0.94em;
2525
word-break: break-word;
2626
border-radius: 0.25rem;
27-
background-color: rgba(255, 229, 100, 0.2);
27+
background-color: rgba(187, 239, 253, 0.325);
2828
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
2929
}
3030

GhostUI/ClientApp/components/controls/dropdown/VDropdown.render.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export default class VDropdown extends Vue {
4444
</button>
4545
<div class='dropdown-menu' ref='dropdownMenu' role='menu'>
4646
<ul class='dropdown-content'>
47-
{this.options.map((option: any, index: number) =>
48-
this.renderListOption(option, index)
49-
)}
47+
{this.options.map((option: any, index: number) => this.renderListOption(option, index))}
5048
</ul>
5149
</div>
5250
</div>

GhostUI/ClientApp/components/loaders/Authenticator.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Authenticator extends Vue {
3030
this.$emit(newValue);
3131
}, this.emitTimeout);
3232
} else {
33-
this.show = newValue === AuthStatusEnum.Process;
33+
this.show = (newValue === AuthStatusEnum.Process);
3434
}
3535
}
3636
}

GhostUI/ClientApp/config/axios.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const configureAxiosInterceptors = (): void => {
1313
);
1414
};
1515

16-
export const handleAxiosError = (error: AxiosError): void => {
16+
const handleAxiosError = (error: AxiosError): void => {
1717
// Error Message Object
1818
const message = {
1919
body: 'Internal Server Error',

GhostUI/ClientApp/store/modules/auth/auth.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Auth extends VuexModule implements IAuthState {
1313
return (this.token || '').length > 0 && (this.status || '').toLowerCase().includes('success');
1414
}
1515

16-
@MutationAction({ mutate: ['token', 'status', 'userName'] })
17-
public async LoginUser(credentials: ICredentials): Promise<any> {
16+
@MutationAction<IAuthState>({ mutate: ['token', 'status', 'userName'] })
17+
public async LoginUser(credentials: ICredentials): Promise<IAuthState> {
1818
try {
1919
const authUser = await AuthApi.login(credentials);
2020
return {

GhostUI/ClientApp/store/modules/auth/types.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface IAuthUser {
1818
}
1919

2020
export interface IAuthState {
21-
token: string;
22-
status: string;
23-
userName: string;
21+
readonly token?: string;
22+
readonly status?: string;
23+
readonly userName?: string;
2424
}

GhostUI/ClientApp/store/modules/form/form.module.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import store from "../../../store";
22
import { IDropdownOption, IFormState } from "./types";
3-
import {
4-
Module,
5-
VuexModule,
6-
Mutation,
7-
getModule
8-
} from "vuex-module-decorators";
3+
import { Module, VuexModule, Mutation, getModule } from "vuex-module-decorators";
94

105
@Module({ dynamic: true, store, name: "form" })
116
class Form extends VuexModule implements IFormState {
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
export interface IDropdownOption {
2-
value: number;
3-
label: string;
2+
readonly value: number;
3+
readonly label: string;
44
}
55

66
export interface IFormState {
7-
count: number;
8-
checkboxValue: boolean;
9-
selectedDropdownOption: {
10-
value: number;
11-
label: string;
12-
};
7+
readonly count: number;
8+
readonly checkboxValue: boolean;
9+
readonly selectedDropdownOption: IDropdownOption;
1310
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export interface IWeatherForecast {
2-
ID: number;
3-
DateFormatted: string;
4-
TemperatureC: number;
5-
TemperatureF: number;
6-
Summary: string;
2+
readonly ID: number;
3+
readonly DateFormatted: string;
4+
readonly TemperatureC: number;
5+
readonly TemperatureF: number;
6+
readonly Summary: string;
77
}
88

99
export interface IWeatherForecastsState {
10-
startDateIndex?: number;
11-
forecasts?: IWeatherForecast[];
10+
readonly startDateIndex?: number;
11+
readonly forecasts?: IWeatherForecast[];
1212
}

GhostUI/ClientApp/store/modules/weather-forecasts/weather-forecasts.module.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import store from "../../../store";
22
import { SampleApi } from "../../../api";
33
import { IWeatherForecast, IWeatherForecastsState } from "./types";
4-
import {
5-
Module,
6-
VuexModule,
7-
MutationAction,
8-
getModule
9-
} from "vuex-module-decorators";
4+
import { Module, VuexModule, MutationAction, getModule } from "vuex-module-decorators";
105

116
@Module({ dynamic: true, store, name: "forecasts" })
127
class WeatherForecast extends VuexModule implements IWeatherForecastsState {
138
public startDateIndex: number = 0;
149
public forecasts: IWeatherForecast[] = [];
1510

16-
@MutationAction({ mutate: ["forecasts", "startDateIndex"] })
17-
public async GetWeatherForecasts(index: number | null): Promise<any> {
11+
@MutationAction<IWeatherForecastsState>({ mutate: ["forecasts", "startDateIndex"] })
12+
public async GetWeatherForecasts(index: number | null): Promise<IWeatherForecastsState> {
1813
try {
1914
const forecasts = await SampleApi.getWeatherForecastsAsync(index || 0);
2015
return {

GhostUI/ClientApp/views/FetchData.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ import {
5454
export default class FetchData extends Vue {
5555
private loading: boolean = false;
5656
57-
get currentStartDateIndex(): number {
58-
return WeatherForecastModule.startDateIndex;
59-
}
60-
6157
get forecasts(): IWeatherForecast[] {
6258
return WeatherForecastModule.forecasts;
6359
}
6460
61+
get currentStartDateIndex(): number {
62+
return WeatherForecastModule.startDateIndex;
63+
}
64+
6565
private created(): void {
6666
if (!this.forecasts || this.forecasts.length === 0) {
6767
this.handleGetWeatherForecasts();

GhostUI/ClientApp/views/Login.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ export default class Login extends Vue {
138138
139139
private onAuthFailure(): void {
140140
this.authStatus = AuthStatusEnum.None;
141-
this.$snotify.error(
142-
`Could not authenticate: ${this.credentials.userName}`,
143-
"Login Error"
144-
);
141+
this.$snotify.error(`Could not authenticate: ${this.credentials.userName}`, "Login Error");
145142
}
146143
}
147144
</script>

GhostUI/HealthChecks/GCInfo/GCInfoHealthCheck.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ public GCInfoHealthCheck(IOptionsMonitor<GCInfoOptions> options)
1616
_options = options;
1717
}
1818

19-
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default(CancellationToken))
19+
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
2020
{
2121
// This example will report degraded status if the application is using more than the configured amount of memory (1gb by default).
2222
// Additionally we include some GC info in the reported diagnostics.
2323
var options = _options.Get(context.Registration.Name);
2424
var allocated = GC.GetTotalMemory(forceFullCollection: false);
25+
2526
var data = new Dictionary<string, object>
2627
{
2728
{ "Allocated", allocated },
@@ -32,7 +33,9 @@ public GCInfoHealthCheck(IOptionsMonitor<GCInfoOptions> options)
3233

3334
// Report failure if the allocated memory is >= the threshold.
3435
// Using context.Registration.FailureStatus means that the application developer can configure how they want failures to appear.
35-
var result = allocated >= options.Threshold ? context.Registration.FailureStatus : HealthStatus.Healthy;
36+
var result = allocated >= options.Threshold
37+
? context.Registration.FailureStatus
38+
: HealthStatus.Healthy;
3639

3740
return Task.FromResult(new HealthCheckResult(
3841
result,

0 commit comments

Comments
 (0)