-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(typings): add class EggLoader #2321
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2321 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 29 29
Lines 825 825
=======================================
Hits 823 823
Misses 2 2 Continue to review full report at Codecov.
|
need commits of eggjs/egg#2321
用于 TS 的框架扩展 framework-ts-example |
commit: 9334658 |
index.d.ts
Outdated
@@ -968,4 +970,60 @@ declare module 'egg' { | |||
? PowerPartial<T[U]> | |||
: T[U] | |||
}; | |||
|
|||
export interface EggLoaderOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer add these to egg-core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯 当时考虑过在 egg-core 里面添加的。不过 egg 里面还需要 import 和 export 感觉有点麻烦
index.d.ts
Outdated
|
||
constructor(options: EggLoaderOptions); | ||
|
||
private getServerEnv(): string; // not exists EggAppInfo['env'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private 的为啥要写出来?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没用的就干掉吧,别注释
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面的 worker 为啥不在 EggLoader 里面写? 补全下其他函数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面的 worker 为啥不在 EggLoader 里面写
没懂
need commits of eggjs/egg#2321
看今天能否处理下,我下午发一个 egg patch。 |
constructor(options: EggLoaderOptions); | ||
|
||
getHomedir(): EggAppInfo['HOME'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EggLoader 里其实有很多暴露出来的方法可能是需要在上层框架中用到的,也需要补一下吧,比如 getLoadUnits
,loadToApp
,loadToContext
这些?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
方法比较多,如果在 EggCore 里面添加 index.d.ts 可能更清晰些。 不过我对 typings 合并(到egg)机制不大清楚
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用,你直接加 d.ts 到 egg-core 中,然后在 egg 中 import 进来就行了,typings 合并到 egg 那个只是适用于上层框架、插件的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whxaxes 你的意思是在 egg-core 项目中添加 egg-core/index.d.ts
文件么?
declare module 'egg' { <--- 'egg' OR 'egg-core' ?
export interface EggAppInfo {
pkg: any; // package.json
name: string; // the application name from package.json
baseDir: string; // current directory of application
env: EggEnvType; // equals to serverEnv
HOME: string; // home directory of the OS
root: string; // baseDir when local and unittest, HOME when other environment
}
export interface EggLoaderOptions {
baseDir: string;
typescript?: boolean;
app: Application;
logger: Logger;
plugins?: any;
}
export class EggLoader {
options: EggLoaderOptions;
constructor(options: EggLoaderOptions);
getHomedir(): EggAppInfo['HOME']
getAppInfo(): EggAppInfo;
}
}
不过 EggAppInfo
这个类型是在 egg/index.d.ts
中定义的啊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以有两种方式
- egg-core 里面
import { EggLoaderOptions } from 'egg'
,这样会循环依赖,但问题不大,运行是没有问题的 - EggLoaderOptions 直接放 egg-core 里面,在 egg 里面
export { EggLoaderOptions } from 'egg-core'
need commits of eggjs/egg#2321
这个可以合并了? |
要 @shepherdwind @whxaxes 看看 |
@atian25 这个可以合了吗 |
EggLoader 先加进来应该也 OK |
CI 没过 |
constructor(options: EggLoaderOptions); | ||
|
||
getHomedir(): EggAppInfo['HOME'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以有两种方式
- egg-core 里面
import { EggLoaderOptions } from 'egg'
,这样会循环依赖,但问题不大,运行是没有问题的 - EggLoaderOptions 直接放 egg-core 里面,在 egg 里面
export { EggLoaderOptions } from 'egg-core'
我看看能否把 EggLoaderOptions 放到 egg-core |
export interface EggLoaderOptions {
baseDir: string;
typescript?: boolean;
app: Application; // <--- 这个是 KoaApplication 的还是 Egg扩展后的的?
logger: Logger;
plugins?: any;
} |
export interface EggLoaderOptions {
baseDir: string;
typescript?: boolean;
app: Application; // <--- 这个是 KoaApplication 的还是 Egg扩展后的的?
logger: Logger;
plugins?: any;
} 问问,楼上那个编辑过的有个弹框提示编辑历史,盖住了内容怎么能去掉呢 |
root, cache, defaultExtension
PowerPartial support by TypeScript v2.8.0+
appveyor v9 过了, v8挂了。啥情况呢 |
ci都过了 |
@whxaxes @waitingsong ci 过了就准备合并了 |
chore(typings): add class EggLoader (#2321)
Checklist
npm test
passesAffected core subsystem(s)
Description of change