Skip to content
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

Merged
merged 15 commits into from
Aug 24, 2018
Merged

chore(typings): add class EggLoader #2321

merged 15 commits into from
Aug 24, 2018

Conversation

waitingsong
Copy link
Contributor

@waitingsong waitingsong commented Apr 5, 2018

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

@codecov
Copy link

codecov bot commented Apr 5, 2018

Codecov Report

Merging #2321 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80528cc...184edcd. Read the comment docs.

waitingsong added a commit to waitingsong/eggjs-examples that referenced this pull request Apr 5, 2018
@waitingsong
Copy link
Contributor Author

waitingsong commented Apr 5, 2018

用于 TS 的框架扩展 framework-ts-example

@waitingsong
Copy link
Contributor Author

commit: 9334658
for: https://github.com/eggjs/examples hackernews-async-ts

2018-04-05_211300

index.d.ts Outdated
@@ -968,4 +970,60 @@ declare module 'egg' {
? PowerPartial<T[U]>
: T[U]
};

export interface EggLoaderOptions {
Copy link
Member

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

Copy link
Contributor Author

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 感觉有点麻烦

@atian25 atian25 requested a review from whxaxes April 8, 2018 10:44
index.d.ts Outdated

constructor(options: EggLoaderOptions);

private getServerEnv(): string; // not exists EggAppInfo['env']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private 的为啥要写出来?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没用的就干掉吧,别注释

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面的 worker 为啥不在 EggLoader 里面写? 补全下其他函数

Copy link
Contributor Author

@waitingsong waitingsong Apr 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面的 worker 为啥不在 EggLoader 里面写

没懂

waitingsong added a commit to waitingsong/eggjs-examples that referenced this pull request Apr 10, 2018
@atian25
Copy link
Member

atian25 commented Apr 12, 2018

看今天能否处理下,我下午发一个 egg patch。

constructor(options: EggLoaderOptions);

getHomedir(): EggAppInfo['HOME']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EggLoader 里其实有很多暴露出来的方法可能是需要在上层框架中用到的,也需要补一下吧,比如 getLoadUnitsloadToApploadToContext 这些?

Copy link
Contributor Author

@waitingsong waitingsong Apr 12, 2018

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)机制不大清楚

Copy link
Member

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 那个只是适用于上层框架、插件的

Copy link
Contributor Author

@waitingsong waitingsong Apr 13, 2018

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 中定义的啊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以有两种方式

  1. egg-core 里面 import { EggLoaderOptions } from 'egg',这样会循环依赖,但问题不大,运行是没有问题的
  2. EggLoaderOptions 直接放 egg-core 里面,在 egg 里面 export { EggLoaderOptions } from 'egg-core'

waitingsong added a commit to waitingsong/eggjs-examples that referenced this pull request Apr 29, 2018
@dead-horse
Copy link
Member

这个可以合并了?

@atian25 atian25 requested a review from shepherdwind May 4, 2018 02:28
@atian25
Copy link
Member

atian25 commented May 4, 2018

@shepherdwind @whxaxes 看看

@popomore
Copy link
Member

popomore commented May 4, 2018

@atian25 这个可以合了吗

@dead-horse dead-horse mentioned this pull request May 5, 2018
4 tasks
@whxaxes
Copy link
Member

whxaxes commented May 10, 2018

EggLoader 先加进来应该也 OK

@dead-horse
Copy link
Member

CI 没过

constructor(options: EggLoaderOptions);

getHomedir(): EggAppInfo['HOME']

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以有两种方式

  1. egg-core 里面 import { EggLoaderOptions } from 'egg',这样会循环依赖,但问题不大,运行是没有问题的
  2. EggLoaderOptions 直接放 egg-core 里面,在 egg 里面 export { EggLoaderOptions } from 'egg-core'

@waitingsong
Copy link
Contributor Author

我看看能否把 EggLoaderOptions 放到 egg-core

@waitingsong
Copy link
Contributor Author

waitingsong commented Jun 13, 2018

  export interface EggLoaderOptions {
    baseDir: string;
    typescript?: boolean;
    app: Application; // <--- 这个是 KoaApplication 的还是 Egg扩展后的的?
    logger: Logger;
    plugins?: any;
  }

@waitingsong
Copy link
Contributor Author

  export interface EggLoaderOptions {
    baseDir: string;
    typescript?: boolean;
    app: Application; // <--- 这个是 KoaApplication 的还是 Egg扩展后的的?
    logger: Logger;
    plugins?: any;
  }

问问,楼上那个编辑过的有个弹框提示编辑历史,盖住了内容怎么能去掉呢

@waitingsong
Copy link
Contributor Author

appveyor v9 过了, v8挂了。啥情况呢

@waitingsong
Copy link
Contributor Author

ci都过了

@popomore
Copy link
Member

popomore commented Aug 24, 2018

@whxaxes @waitingsong ci 过了就准备合并了

@popomore popomore merged commit db1286d into eggjs:master Aug 24, 2018
popomore pushed a commit that referenced this pull request Aug 24, 2018
chore(typings): add class EggLoader (#2321)
@waitingsong waitingsong deleted the ts branch August 24, 2018 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants