Skip to content

Commit

Permalink
fix: dont import default value
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 13, 2024
1 parent 9ff7f76 commit 8607283
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ test/fixtures/*/timing.json
lib/
.tshy*
dist
.package-lock.json
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/eggjs/egg-core#readme",
"dependencies": {
"@eggjs/koa": "^2.18.2",
"@eggjs/koa": "^2.19.2",
"@eggjs/router": "^3.0.5",
"@eggjs/utils": "^4.0.2",
"egg-logger": "^3.5.0",
Expand Down Expand Up @@ -98,5 +98,6 @@
}
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts"
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js"
}
9 changes: 3 additions & 6 deletions src/egg.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable prefer-spread */
import assert from 'node:assert';
import { debuglog } from 'node:util';
import is from 'is-type-of';
import KoaApplication from '@eggjs/koa';
import { Application as KoaApplication } from '@eggjs/koa';
import type { ContextDelegation, MiddlewareFunc } from '@eggjs/koa';
import { EggConsoleLogger } from 'egg-logger';
import { RegisterOptions, ResourcesController, EggRouter as Router } from '@eggjs/router';
Expand Down Expand Up @@ -157,10 +156,8 @@ export class EggCore extends KoaApplication {
* override koa's app.use, support generator function
* @since 1.0.0
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
use(fn: MiddlewareFunc) {
assert(is.function(fn), 'app.use() requires a function');
assert(typeof fn === 'function', 'app.use() requires a function');
debug('[use] add middleware: %o', fn._name || fn.name || '-');
this.middleware.push(fn);
return this;
Expand Down Expand Up @@ -226,7 +223,7 @@ export class EggCore extends KoaApplication {
* Execute scope after loaded and before app start.
*
* Notice:
* This method is now NOT recommanded and reguarded as a deprecated one,
* This method is now NOT recommended and regarded as a deprecated one,
* For plugin development, we should use `didLoad` instead.
* For application development, we should use `willReady` instead.
*
Expand Down
6 changes: 3 additions & 3 deletions src/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'node:assert';
import { EventEmitter } from 'node:events';
import { debuglog } from 'node:util';
import is, { isClass } from 'is-type-of';
import ReadyObject from 'get-ready';
import { isClass } from 'is-type-of';
import { Ready as ReadyObject } from 'get-ready';
import type { ReadyFunctionArg } from 'get-ready';
import { Ready } from 'ready-callback';
import { EggConsoleLogger } from 'egg-logger';
Expand Down Expand Up @@ -184,7 +184,7 @@ export class Lifecycle extends EventEmitter {
}

registerBeforeClose(fn: Fun) {
assert(is.function(fn), 'argument should be function');
assert(typeof fn === 'function', 'argument should be function');

Check warning on line 187 in src/lifecycle.ts

View check run for this annotation

Codecov / codecov/patch

src/lifecycle.ts#L187

Added line #L187 was not covered by tests
assert(this.#isClosed === false, 'app has been closed');
this.#closeFunctionSet.add(fn);
}
Expand Down
2 changes: 1 addition & 1 deletion src/loader/egg_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import assert from 'node:assert';
import { debuglog, inspect } from 'node:util';
import { isAsyncFunction, isClass, isGeneratorFunction, isObject } from 'is-type-of';
import homedir from 'node-homedir';
import { homedir } from 'node-homedir';
import type { Logger } from 'egg-logger';
import { getParamNames, readJSONSync } from 'utility';
import { extend } from 'extend2';
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/egg-esm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Application extends EggCore {

constructor(options: EggCoreInitOptions = {}) {
super(options);
this.on('error', err => {
this.on('error', (err: any) => {
console.error(err);
});
}
Expand Down

0 comments on commit 8607283

Please sign in to comment.