Skip to content

Commit

Permalink
fix: fix TS typing error (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingchuno committed Feb 24, 2021
1 parent 6bd6002 commit 001a86b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency` by downgrade to `mongodb@3.6.3`
- Revert update session when touch (#351)
- Fix cannot read property `lastModified` of null
- Fix TS typing error

## [4.1.0] - 2021-02-22

Expand Down
16 changes: 8 additions & 8 deletions src/lib/MongoStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type ConcretConnectMongoOptions = {
crypto: ConcretCryptoOptions
}

type ErrorOrNull = Error | null
// type ErrorOrNull = Error | null

type InternalSessionType = {
_id: string
Expand Down Expand Up @@ -216,7 +216,7 @@ export default class MongoStore extends session.Store {
*/
get(
sid: string,
callback: (err: ErrorOrNull, session?: session.SessionData | null) => void
callback: (err: any, session?: session.SessionData | null) => void
): void {
;(async () => {
try {
Expand Down Expand Up @@ -267,7 +267,7 @@ export default class MongoStore extends session.Store {
set(
sid: string,
session: session.SessionData,
callback: (err: ErrorOrNull) => void = noop
callback: (err: any) => void = noop
): void {
;(async () => {
try {
Expand Down Expand Up @@ -338,7 +338,7 @@ export default class MongoStore extends session.Store {
touch(
sid: string,
session: session.SessionData & { lastModified?: Date },
callback: (err: ErrorOrNull) => void = noop
callback: (err: any) => void = noop
): void {
;(async () => {
try {
Expand Down Expand Up @@ -394,7 +394,7 @@ export default class MongoStore extends session.Store {
*/
all(
callback: (
err: ErrorOrNull,
err: any,
obj?:
| session.SessionData[]
| { [sid: string]: session.SessionData }
Expand Down Expand Up @@ -435,7 +435,7 @@ export default class MongoStore extends session.Store {
* Destroy/delete a session from the store given a session ID (sid)
* @param sid session ID
*/
destroy(sid: string, callback: (err: ErrorOrNull) => void = noop): void {
destroy(sid: string, callback: (err: any) => void = noop): void {
debug(`MongoStore#destroy=${sid}`)
this.collectionP
.then((colleciton) =>
Expand All @@ -454,7 +454,7 @@ export default class MongoStore extends session.Store {
/**
* Get the count of all sessions in the store
*/
length(callback: (err: ErrorOrNull, length: number) => void): void {
length(callback: (err: any, length: number) => void): void {
debug('MongoStore#length()')
this.collectionP
.then((collection) => collection.countDocuments())
Expand All @@ -466,7 +466,7 @@ export default class MongoStore extends session.Store {
/**
* Delete all sessions from the store.
*/
clear(callback: (err: ErrorOrNull) => void = noop): void {
clear(callback: (err: any) => void = noop): void {
debug('MongoStore#clear()')
this.collectionP
.then((collection) => collection.drop())
Expand Down
2 changes: 1 addition & 1 deletion src/test/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ConnectMongoOptions } from '../lib/MongoStore'

declare module 'express-session' {
interface SessionData {
views: number
[key: string]: any
}
}

Expand Down

0 comments on commit 001a86b

Please sign in to comment.