Skip to content

Commit f8ad10e

Browse files
committed
fix: optional typing
1 parent febe89e commit f8ad10e

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

src/site/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as urls from '../utils/urls'
33

44
export class BaseSiteComponent {
55
protected session?: session.Session;
6-
constructor(params: session.Session | undefined | {
6+
constructor(params?: session.Session | {
77
session?: session.Session
88
}) {
99
if (params instanceof session.Session || params === undefined) {

src/site/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class PartialProject extends base.BaseSiteComponent {
2323
params.id = 0;
2424
}
2525

26-
super({session: params.session});
26+
super(params.session);
2727

2828
this.id = params.id;
2929
this.title = params.title;

src/site/session.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Session extends base.BaseSiteComponent{
3838
params.password = '';
3939
}
4040

41-
super({});
41+
super();
4242
this.session = this;
4343

4444
this.id = params.id;
@@ -115,9 +115,11 @@ export class Session extends base.BaseSiteComponent{
115115
export function decode_session_id(session_id: string): [Record<string, string>, Date] {
116116
const [p1, p2] = session_id.split(':');
117117

118+
expect(p2).toBeDefined();
119+
118120
return [
119121
JSON.parse(zlib.inflateSync(Buffer.from(p1 + '==', 'base64url')).toString()),
120-
new Date(commons.b62_decode(p2) * 1000)
122+
new Date(commons.b62_decode(p2!) * 1000)
121123
];
122124
}
123125

src/site/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import * as session from './session';
44
import * as urls from '../utils/urls'
55

66
export class User extends base.BaseSiteComponent {
7-
id?: number;
8-
name?: string;
7+
id: number | undefined;
8+
name: string | undefined;
99

1010
constructor(params: {
1111
name?: string;
1212
id?: number;
1313
session?: session.Session
1414
}) {
15-
super({session: params.session});
15+
super(params.session);
1616

1717
this.id = params.id;
1818
this.name = params.name;

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
// Stricter Typechecking Options
2727
"noUncheckedIndexedAccess": true,
28-
"exactOptionalPropertyTypes": true,
28+
"exactOptionalPropertyTypes": false,
2929

3030
// Style Options
3131
// "noImplicitReturns": true,

0 commit comments

Comments
 (0)