Skip to content

Commit

Permalink
fix(Typescripts): perfect typescripts
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Dec 19, 2018
1 parent 04695d9 commit 4459f14
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"shallow-element-equals": "^1.0.1"
},
"devDependencies": {
"@alifd/api-extractor": "^3.0.0",
"@alifd/api-extractor": "^3.4.0",
"@alifd/babel-preset-next": "^2.0.0",
"@alifd/doc-parser": "^1.0.0",
"@alifd/dts-generator": "^1.0.0",
Expand Down
15 changes: 14 additions & 1 deletion scripts/build/export-api-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@ const fs = require('fs-extra');
const apiExtractor = require('@alifd/api-extractor');
const tsgen = require('@alifd/dts-generator');
const { logger } = require('../utils');
const config = require('../config');

const cwd = process.cwd();
const parentMap = config.child2parent;
const parentPathMap = {};

Object.keys(parentMap).forEach(child => {
const parent = parentMap[child];
const component = parent.split('.')[0].toLowerCase();

parentPathMap[child] = {
name: parent,
path: path.join(cwd, 'src', component)
};
});

module.exports = function (options) {
const libPath = path.join(cwd, 'lib');
Expand All @@ -20,7 +33,7 @@ module.exports = function (options) {

const srcComponentPath = path.join(cwd, 'src', shortName);
const libComponentPath = path.join(cwd, 'lib', shortName);
const apiInfo = apiExtractor.extract(srcComponentPath);
const apiInfo = apiExtractor.extract(srcComponentPath, {}, parentPathMap);

const apiPath = path.join(libComponentPath, 'api-schema.json');
const exportDTSPath = path.join(libComponentPath, 'index.d.ts');
Expand Down
15 changes: 15 additions & 0 deletions scripts/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
module.exports = {
child2parent: {
// Overlay.Popup inherent from Overlay, add this to generate entire d.ts files
'Overlay.Popup': 'Overlay',
Dropdown: 'Overlay.Popup',
'Form.Submit': 'Button',
'Form.Reset': 'Button',
Nav: 'Menu',
'Nav.Group': 'Menu.Group',
'Nav.Item': 'Menu.Item',
'Nav.PopupItem': 'Menu.PopupItem',
'Nav.SubMenu': 'Menu.SubMenu',
Search: 'Select.AutoComplete',
'Upload.Card': 'Upload',
'Upload.Drager': 'Upload'
},
components: [
'affix',
'animate',
Expand Down

0 comments on commit 4459f14

Please sign in to comment.