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

feat: add TypeScript framework-ts example #68

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

waitingsong
Copy link
Contributor

@waitingsong waitingsong commented Apr 5, 2018

need commits of eggjs/egg#2321

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

@waitingsong
Copy link
Contributor Author

waitingsong commented Apr 5, 2018

已知问题

  • route 导入模块
    如下图

2018-04-05_195127

如果改为导入框架模块 yadan-ts,就会爆一堆类型错误。如果使用当前的 'egg' 模块,那么应用 app/package.json 又需要引入 egg 不知道是否会导致其他问题?

  "dependencies": {
    "egg": "^2.6.0",
    "egg-scripts": "^2.6.0",
    "yadan-ts": "../yadan"
  },
  • 调用框架服务的类型推断

2018-04-05_200930

目前无法读取到框架 yadan-tsctx.service 的类型,只能使用上图的丑陋定义方法

@atian25 atian25 requested a review from whxaxes April 9, 2018 11:59
Copy link
Member

@whxaxes whxaxes left a comment

Choose a reason for hiding this comment

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

参考 hackernews-async-ts,以及根据天猪的博文改一下吧,好像这风格不太一样



export class DefaultConfig {
}
Copy link
Member

Choose a reason for hiding this comment

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

用新的写法吧,不要用这种旧的了,看一下天猪那篇文档

"block-spacing": [true, "always"], // 强制在单行代码块中使用一致的空格
"brace-style": [true, "stroustrup", { "allowSingleLine": true }], // 大括号风格要求
"comment-format": [true, "check-space", {"ignore-words": ["-", "+"]}], // 强制在注释中 // 或 /* 使用一致的空格
"curly": [true, "ignore-same-line"], // 要求遵循大括号约定
Copy link
Member

Choose a reason for hiding this comment

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

tslint 的规则感觉很多冗余代码

"module": "commonjs", /* 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
"newLine": "lf",
"noFallthroughCasesInSwitch": true,
// "outDir": "./dist",
Copy link
Member

Choose a reason for hiding this comment

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

为什么是注释而不是删掉?

"emitDecoratorMetadata": true,
"importHelpers": false,
"inlineSourceMap": true,
"module": "commonjs", /* 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
Copy link
Member

Choose a reason for hiding this comment

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

应该还少了个 moduleResolution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moduleResolution 在 'commonjs' 模块值时默认是 'node', 可以不用显示设置了

Copy link
Member

Choose a reason for hiding this comment

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

ok

@waitingsong
Copy link
Contributor Author

有空再按照茶叶蛋的规范更新

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.

2 participants