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: improve d.ts with ts support #2306

Merged
merged 20 commits into from
Apr 4, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,29 @@ declare module 'egg' {

export type LoggerLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';

/**
* egg app info
* @example
* ```js
* // config/config.default.ts
* import { EggAppInfo } from 'egg';
*
* export default (appInfo: EggAppInfo) => {
* return {
* keys: appInfo.name + '123456',
* };
* }
* ```
*/
export interface EggAppInfo {
Copy link
Member

Choose a reason for hiding this comment

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

顶部加个. jsdoc?说明下这个用在哪里的,如给个 config 的示例

Copy link
Member Author

Choose a reason for hiding this comment

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

加了

Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

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

@shepherdwind 之前你们 example 那边写的 config 理解有问题。

export default (appInfo: EggAppInfo, appConfig?: EggAppConfig) => {} 这才是 config.{env}.js 的签名

Copy link
Member

Choose a reason for hiding this comment

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

不过 appConfig 这个没几个人知道,哈哈

pkg: string; // package.json
Copy link
Member

Choose a reason for hiding this comment

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

这里错了, pkg 是 json

Copy link
Member Author

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.

rebase

Copy link
Member Author

Choose a reason for hiding this comment

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

改了

name: string; // the application name from package.json
baseDir: string; // current directory of application
env: string; // equals to serverEnv
HOME: string; // home directory of the OS
root: string; // baseDir when local and unittest, HOME when other environment
}

export interface EggAppConfig {
workerStartTimeout: number;
baseDir: string;
Expand Down