Skip to content

Commit

Permalink
Merge pull request #998 from youluna/fix-warning-and-ts
Browse files Browse the repository at this point in the history
Add d.ts. for locale & prevent some warning
  • Loading branch information
youluna committed Aug 13, 2019
2 parents cf66a80 + e1801b6 commit 16c9cfe
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 11 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
"test:a11y": "node --max_old_space_size=8192 ./scripts/test/a11y-index.js",
"order-var": "node ./scripts/order-var.js",
"eslint": "eslint '@(src|scripts)/**/*.@(js|jsx)' && eslint --fix 'docs/**/@(demo|theme)/*.@(md)'",
"tslint": "tsc types/**/*.d.ts",
"tslint": "tsc",
"prettierjs": "prettier --write '@(src|test|scripts)/**/*.@(js|jsx)'",
"stylelint": "stylelint --fix 'src/**/*.@(css|scss)'",
"commitmsg": "commitlint -E GIT_PARAMS",
"precommit": "lint-staged",
"changelog": "node ./scripts/changelog.js",
"prepub": "npm run tslint && npm run eslint && npm run stylelint && npm run changelog && npm run build && npm run check && npm run docs && npm run pack && npm run pack -- minimize && npm run pack-adaptor"
"prepub": "npm run tslint && npm run eslint && npm run stylelint && npm run changelog && npm run build && npm run tslint && npm run check && npm run docs && npm run pack && npm run pack -- minimize && npm run pack-adaptor"
},
"lint-staged": {
"types/**/*.d.ts": [
Expand Down Expand Up @@ -83,7 +83,7 @@
"devDependencies": {
"@alifd/adaptor-generate": "^0.2.3",
"@alifd/adaptor-helper": "^0.1.3",
"@alifd/api-extractor": "^3.5.1",
"@alifd/api-extractor": "^3.5.2",
"@alifd/babel-preset-next": "^2.0.0",
"@alifd/doc-parser": "^1.0.0",
"@alifd/dts-generator": "^1.0.3",
Expand Down
13 changes: 12 additions & 1 deletion scripts/build/export-api-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ module.exports = function(options) {
fs.writeFileSync(apiPath, apiString);
fs.writeFileSync(
exportDTSPath,
`export * from '../../types/${shortName}';
`import ${apiInfo.name} from '../../types/${shortName}';
export * from '../../types/${shortName}';
export default ${apiInfo.name};
`
);
// tsgen(apiInfo).then(apiData => {
Expand All @@ -72,6 +74,15 @@ module.exports = function(options) {
}
});

// generate d.ts for locale
['zh-cn', 'en-us', 'ja-jp', 'zh-tw'].forEach(file => {
const localePath = path.join(cwd, 'lib', 'locale', `${file}.d.ts`);
fs.writeFileSync(
localePath,
`export * from '../../types/locale/${file}';`
);
});

// hack Field
entries.push('export const Field: any;');

Expand Down
1 change: 0 additions & 1 deletion src/balloon/inner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class BalloonInner extends React.Component {
role="button"
aria-label={locale.close}
tabIndex="0"
href="javascript:void(0);"
className={`${_prefix}-close`}
onClick={onClose}
>
Expand Down
1 change: 0 additions & 1 deletion src/dialog/inner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export default class Inner extends Component {
<a
role="button"
aria-label={locale.close}
href="javascript:;"
className={`${prefix}dialog-close`}
onClick={onClose}
>
Expand Down
2 changes: 1 addition & 1 deletion src/drawer/inner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Inner extends Component {
className: PropTypes.string,
closeable: PropTypes.bool,
role: PropTypes.string,
placement: PropTypes.oneOfType(['top', 'right', 'bottom', 'left']),
placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
rtl: PropTypes.bool,
};

Expand Down
1 change: 0 additions & 1 deletion src/message/message.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class Message extends Component {
<a
role="button"
aria-label={locale.closeAriaLabel}
href="javascript:;"
className={`${messagePrefix}-close`}
onClick={this.onClose}
>
Expand Down
1 change: 0 additions & 1 deletion src/table/base/sort.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default class Sort extends React.Component {
const icons = ['asc', 'desc'].map(sortOrder => {
return (
<a
href="javascript:;"
key={sortOrder}
className={sortStatus === sortOrder ? 'current' : ''}
>
Expand Down
1 change: 1 addition & 0 deletions src/table/list/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class GroupListRow extends Row {
cellRef,
getCellProps,
locale,
wrapper,
rtl,
...others
} = this.props;
Expand Down
2 changes: 1 addition & 1 deletion types/tsconfig.json → tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"removeComments": true,
"sourceMap": true
},
"include": ["types/**/*"]
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion types/config-provider/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface ConfigProviderProps {
/**
* 设备类型,针对不同的设备类型组件做出对应的响应式变化
*/
device: 'tablet' | 'desktop' | 'phone',
device?: 'tablet' | 'desktop' | 'phone',
/**
* 组件树
*/
Expand Down
126 changes: 126 additions & 0 deletions types/locale/default.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
export interface locale {
momentLocale: string;
Timeline: {
expand: string;
fold: string;
};
Balloon: {
close: string;
};
Card: {
expand: string;
fold: string;
};
Calendar: {
today: string;
now: string;
ok: string;
clear: string;
month: string;
year: string;
prevYear: string;
nextYear: string;
prevMonth: string;
nextMonth: string;
prevDecade: string;
nextDecade: string;
yearSelectAriaLabel: string;
monthSelectAriaLabel: string;
};
DatePicker: {
placeholder: string;
datetimePlaceholder: string;
monthPlaceholder: string;
yearPlaceholder: string;
now: string;
selectTime: string;
selectDate: string;
ok: string;
clear: string;
startPlaceholder: string;
endPlaceholder: string;
hour: string;
minute: string;
second: string;
};
Dialog: {
close: string;
ok: string;
cancel: string;
};
Message: {
closeAriaLabel: string;
};
Pagination: {
prev: string;
next: string;
goTo: string;
page: string;
go: string;
total: string;
labelPrev: string;
labelNext: string;
inputAriaLabel: string;
selectAriaLabel: string;
pageSize: string;
};
Input: {
clear: string;
};
Select: {
selectPlaceholder: string;
autoCompletePlaceholder: string;
notFoundContent: string;
maxTagPlaceholder: string;
};
Table: {
empty: string;
ok: string;
reset: string;
asc: string;
desc: string;
expanded: string;
folded: string;
filter: string;
selectAll: string;
};
TimePicker: {
placeholder: string;
clear: string;
hour: string;
minute: string;
second: string;
};
Transfer: {
items: string;
item: string;
moveAll: string;
searchPlaceholder: string;
moveToLeft: string;
moveToRight: string;
};
Upload: {
card: {
cancel: string;
addPhoto: string;
download: string;
delete: string;
};
drag: {
text: string;
hint: string;
};
upload: {
delete: string;
};
};
Search: {
buttonText: string;
};
Tag: {
delete: string;
};
Rating: {
description: string;
};
}
1 change: 1 addition & 0 deletions types/locale/en-us.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './default';
1 change: 1 addition & 0 deletions types/locale/ja-jp.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './default';
1 change: 1 addition & 0 deletions types/locale/zh-cn.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './default';
1 change: 1 addition & 0 deletions types/locale/zh-tw.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './default';

0 comments on commit 16c9cfe

Please sign in to comment.