Skip to content

Commit

Permalink
update TS definition, docs & dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Diablohu committed Sep 5, 2019
1 parent 2c12501 commit 93c60e1
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 36 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.11.6

**2019-09-05**

核心

- 更新 TS 定义
- 更新依赖包 patch 版本号

## 0.11.5

**2019-08-30**
Expand Down
2 changes: 2 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ module.exports = {

_默认值解释:_ 文件名以 `.component.css` `.view.css``.module.css` (扩展名可为 `css` `less` `sass`) 为结尾的文件会当作组件 CSS,其他文件会被当做全局 CSS。

_注:_ _TypeScript_ 项目中,如果修改了该配置,针对组件 CSS 对象的默认的 TS 定义声明会失效。

```javascript
module.exports = {
// 默认值
Expand Down
2 changes: 2 additions & 0 deletions docs/css.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ module.exports = {

_默认规则解释:_ 文件名以 `.component.css` `.view.css``.module.css` (扩展名可为 `css` `less` `sass`) 为结尾的文件会当作组件 CSS,其他文件会被当做全局 CSS。

_注:_ _TypeScript_ 项目中,如果修改了上述配置,针对组件 CSS 对象的默认的 TS 定义声明会失效。

**组件 CSS hash 字符串长度**

通过配置项 `classNameHashLength` 可设定组件 CSS hash 字符串长度。
Expand Down
2 changes: 1 addition & 1 deletion docs/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TSComponentClass extends React.Component<ComponentProps & ExtendedProps> {
const { className, children } = this.props;
return (
<div
className={this.props.className}
className={className}
data-custom-props={this.props.customProps}
data-class-name={this.props['data-class-name']}
data-koot-test-page="page-ts"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"cheerio": "^1.0.0-rc.3",
"crlf": "^1.1.1",
"eslint": "^6.3.0",
"eslint-config-koot": "^1.2.1",
"eslint-config-koot": "^1.2.2",
"fs-extra": "^8.1.0",
"husky": "^3.0.5",
"inquirer": "^7.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/koot-boilerplate/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"@server/*": ["./src/server/*"],
"~Assets": ["./src/assets"],
"~Assets/*": ["./src/assets/*"],
"~/*": ["./src/*"]
"~/*": ["./src/*"],
"@types": ["./types"],
"@types/*": ["./types/*"]
}
},
"exclude": [".*", "dist", "dist*", "node_modules"]
Expand Down
3 changes: 2 additions & 1 deletion packages/koot-boilerplate/koot.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ module.exports = {
'@server': path.resolve('./src/server'),
'@store': path.resolve('./src/store'),
'@views': path.resolve('./src/views'),
'~vars.less': path.resolve('./src/constants/less/_all.less')
'~vars.less': path.resolve('./src/constants/less/_all.less'),
'@types': path.resolve('./types')
},

defines: {
Expand Down
4 changes: 2 additions & 2 deletions packages/koot-boilerplate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"babel-eslint": "^10.0.3",
"cssnano": "^4.1.10",
"eslint": "^6.3.0",
"eslint-config-koot": "^1.2.1",
"eslint-config-koot": "^1.2.2",
"husky": "^3.0.5",
"lint-staged": "^9.2.5",
"normalize.css": "^8.0.1",
"prettier": "^1.18.2",
"prettier-eslint": "^9.0.0",
"redux-logger": "^3.0.6",
"svg-url-loader": "^3.0.1"
"svg-url-loader": "^3.0.2"
},
"bugs": {
"url": "https://github.com/cmux/koot/issues"
Expand Down
7 changes: 2 additions & 5 deletions packages/koot-boilerplate/src/views/ts-example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link } from 'react-router';

import Icon from '@components/icon';

import svgTS from '@assets/typescript.svg';
import styles from './index.module.less';

// ============================================================================
Expand Down Expand Up @@ -72,11 +73,7 @@ class TSComponentClass extends React.Component<ComponentProps & ExtendedProps> {
data-class-name={this.props['data-class-name']}
data-koot-test-page="page-ts"
>
<img
src={require('@assets/typescript.svg')}
className="logo"
alt="TypeScript LOGO"
/>
<img src={svgTS} className="logo" alt="TypeScript LOGO" />
<p className="msg-big">{__('pages.ts.msg')}</p>
<p className="msg-small">{__('pages.ts.msgCheckFile')}</p>
<Link to="/start" className="back">
Expand Down
6 changes: 4 additions & 2 deletions packages/koot-boilerplate/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
"@server/*": ["./src/server/*"],
"~Assets": ["./src/assets"],
"~Assets/*": ["./src/assets/*"],
"~/*": ["./src/*"]
"~/*": ["./src/*"],
"@types": ["./types"],
"@types/*": ["./types/*"]
}
},
"include": ["src"]
"include": ["src", "types/**/*.ts"]
}
30 changes: 30 additions & 0 deletions packages/koot-boilerplate/types/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** 图片引用 URL,文件名经过 hash 处理 */
declare module '*.jpg' {
const ImagePath: string;
export = ImagePath;
}
/** 图片引用 URL,文件名经过 hash 处理 */
declare module '*.jpeg' {
const ImagePath: string;
export = ImagePath;
}
/** 图片引用 URL,文件名经过 hash 处理 */
declare module '*.png' {
const ImagePath: string;
export = ImagePath;
}
/** 图片引用 URL,文件名经过 hash 处理 */
declare module '*.apng' {
const ImagePath: string;
export = ImagePath;
}
/** 图片引用 URL,文件名经过 hash 处理 */
declare module '*.gif' {
const ImagePath: string;
export = ImagePath;
}
/** SVG 引用 URL,文件名经过 hash 处理 */
declare module '*.svg' {
const ImagePath: string;
export = ImagePath;
}
40 changes: 26 additions & 14 deletions packages/koot/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ declare function __(

// ============================================================================

declare type KootComponentStyleObject = {
declare interface KootModularStyleObject {
/**
* 组件 `className`
* - 仅为本组件 CSS 的 `className`,不包含父组件通过 `props` 传入的
Expand All @@ -128,52 +128,64 @@ declare type KootComponentStyleObject = {
* 组件 CSS 代码内容
*/
css: string;
};
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.module.css' {
const kootComponentStyleCSS: KootComponentStyleObject;
const kootComponentStyleCSS: KootModularStyleObject;
export = kootComponentStyleCSS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.component.css' {
const kootComponentStyleCSS: KootComponentStyleObject;
const kootComponentStyleCSS: KootModularStyleObject;
export = kootComponentStyleCSS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.view.css' {
const kootComponentStyleCSS: KootComponentStyleObject;
const kootComponentStyleCSS: KootModularStyleObject;
export = kootComponentStyleCSS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.module.sass' {
const kootComponentStyleSASS: KootComponentStyleObject;
const kootComponentStyleSASS: KootModularStyleObject;
export = kootComponentStyleSASS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.component.sass' {
const kootComponentStyleSASS: KootComponentStyleObject;
const kootComponentStyleSASS: KootModularStyleObject;
export = kootComponentStyleSASS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.view.sass' {
const kootComponentStyleSASS: KootComponentStyleObject;
const kootComponentStyleSASS: KootModularStyleObject;
export = kootComponentStyleSASS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.module.scss' {
const kootComponentStyleSCSS: KootComponentStyleObject;
const kootComponentStyleSCSS: KootModularStyleObject;
export = kootComponentStyleSCSS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.component.scss' {
const kootComponentStyleSCSS: KootComponentStyleObject;
const kootComponentStyleSCSS: KootModularStyleObject;
export = kootComponentStyleSCSS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.view.scss' {
const kootComponentStyleSCSS: KootComponentStyleObject;
const kootComponentStyleSCSS: KootModularStyleObject;
export = kootComponentStyleSCSS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.module.less' {
const kootComponentStyleLESS: KootComponentStyleObject;
const kootComponentStyleLESS: KootModularStyleObject;
export = kootComponentStyleLESS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.component.less' {
const kootComponentStyleLESS: KootComponentStyleObject;
const kootComponentStyleLESS: KootModularStyleObject;
export = kootComponentStyleLESS;
}
/** _Koot.js_ 组件 CSS 对象 */
declare module '*.view.less' {
const kootComponentStyleLESS: KootComponentStyleObject;
const kootComponentStyleLESS: KootModularStyleObject;
export = kootComponentStyleLESS;
}
6 changes: 3 additions & 3 deletions packages/koot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@babel/preset-typescript": "^7.3.3",
"@babel/register": "^7.5.5",
"@hot-loader/react-dom": "^16.9.0",
"@types/node": "^12.7.3",
"@types/node": "^12.7.4",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.2",
Expand All @@ -71,7 +71,7 @@
"chalk": "^2.4.2",
"classlist-polyfill": "^1.2.0",
"cli-spinners": "^2.2.0",
"commander": "^3.0.0",
"commander": "^3.0.1",
"compression-webpack-plugin": "^3.0.0",
"cookie": "^0.4.0",
"copy-webpack-plugin": "^5.0.4",
Expand Down Expand Up @@ -138,7 +138,7 @@
"webpack": "^4.39.3",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-config": "^7.5.0",
"webpack-dev-middleware": "^3.7.0",
"webpack-dev-middleware": "^3.7.1",
"webpack-dev-server": "^3.8.0",
"webpack-hot-middleware": "^2.25.0",
"xmlify": "^1.1.0",
Expand Down
6 changes: 3 additions & 3 deletions test/projects/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@babel/preset-typescript": "^7.3.3",
"@babel/register": "^7.5.5",
"@hot-loader/react-dom": "^16.9.0",
"@types/node": "^12.7.3",
"@types/node": "^12.7.4",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.2",
Expand All @@ -67,7 +67,7 @@
"chalk": "^2.4.2",
"classlist-polyfill": "^1.2.0",
"cli-spinners": "^2.2.0",
"commander": "^3.0.0",
"commander": "^3.0.1",
"compression-webpack-plugin": "^3.0.0",
"cookie": "^0.4.0",
"copy-webpack-plugin": "^5.0.4",
Expand Down Expand Up @@ -133,7 +133,7 @@
"webpack": "^4.39.3",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-config": "^7.5.0",
"webpack-dev-middleware": "^3.7.0",
"webpack-dev-middleware": "^3.7.1",
"webpack-dev-server": "^3.8.0",
"webpack-hot-middleware": "^2.25.0",
"xmlify": "^1.1.0",
Expand Down
6 changes: 3 additions & 3 deletions test/projects/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@babel/preset-typescript": "^7.3.3",
"@babel/register": "^7.5.5",
"@hot-loader/react-dom": "^16.9.0",
"@types/node": "^12.7.3",
"@types/node": "^12.7.4",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.2",
Expand All @@ -82,7 +82,7 @@
"chalk": "^2.4.2",
"classlist-polyfill": "^1.2.0",
"cli-spinners": "^2.2.0",
"commander": "^3.0.0",
"commander": "^3.0.1",
"compression-webpack-plugin": "^3.0.0",
"cookie": "^0.4.0",
"copy-webpack-plugin": "^5.0.4",
Expand Down Expand Up @@ -148,7 +148,7 @@
"webpack": "^4.39.3",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-config": "^7.5.0",
"webpack-dev-middleware": "^3.7.0",
"webpack-dev-middleware": "^3.7.1",
"webpack-dev-server": "^3.8.0",
"webpack-hot-middleware": "^2.25.0",
"xmlify": "^1.1.0",
Expand Down

0 comments on commit 93c60e1

Please sign in to comment.