@@ -47,15 +47,15 @@ export interface Module {
4747 * @param {Boolean } isSort 是否需要排序
4848 * @returns 模块对象
4949 */
50- const getAllModules = ( isSort ) => {
50+ const getAllModules = ( isSort : boolean ) => {
5151 return getSortModules ( { filterIntercept : ( ) => true , isSort } )
5252}
5353
5454/**
5555 * @param {String } key 根据模块对象的 Key 获取对应的值
5656 * @returns 模块对象
5757 */
58- const getModuleInfo = ( key ) => {
58+ const getModuleInfo = ( key : string ) => {
5959 return moduleMap [ key ] || { }
6060}
6161
@@ -66,7 +66,10 @@ const getModuleInfo = (key) => {
6666 * @param {Boolean } isOriginal 是否取原始数据
6767 * @param {Boolean } isSort 是否需要排序
6868 */
69- const getByName = ( { name, inversion = false , isOriginal = false , isSort = true } ) => {
69+ const getByName = (
70+ { name, inversion = false , isOriginal = false , isSort = true } :
71+ { name : string ; inversion : boolean ; isOriginal : boolean ; isSort : boolean }
72+ ) => {
7073 const callback = ( item ) => {
7174 const result = new RegExp ( `/${ name } /|^vue-${ name } /` ) . test ( item . path )
7275 return inversion ? ! result : result
@@ -80,7 +83,7 @@ const getByName = ({ name, inversion = false, isOriginal = false, isSort = true
8083 * @private
8184 * @param {Function } filterIntercept 搜索条件
8285 */
83- const getModules = ( filterIntercept ) => {
86+ const getModules = ( filterIntercept : Function ) => {
8487 let modules = { }
8588
8689 if ( typeof filterIntercept === 'function' ) {
@@ -104,7 +107,7 @@ const getModules = (filterIntercept) => {
104107 * @param {Function } filterIntercept 搜索条件
105108 * @param {Boolean } isSort 是否需要排序
106109 */
107- const getSortModules = ( { filterIntercept, isSort = true } ) => {
110+ const getSortModules = ( { filterIntercept, isSort = true } : { filterIntercept : Function ; isSort : boolean } ) => {
108111 let modules : Module [ ] = [ ]
109112 let componentCount = 0
110113 const importName = '@opentiny/vue'
@@ -119,7 +122,7 @@ const getSortModules = ({ filterIntercept, isSort = true }) => {
119122 // 这段逻辑暂时没有用到
120123 const componentName = dirs . slice ( 1 , dirs . indexOf ( 'src' ) )
121124 // UpperName: Todo
122- component . UpperName = utils . capitalizeKebabCase ( componentName . pop ( ) )
125+ component . UpperName = utils . capitalizeKebabCase ( componentName . pop ( ) ?? '' )
123126
124127 // LowerName: todo
125128 component . LowerName = utils . kebabCase ( { str : component . UpperName } )
@@ -331,7 +334,7 @@ const isNotArrayObject = (sortData, key, setIndex) => {
331334 let sortItem = { }
332335
333336 if ( typeof dataItem !== 'object' ) {
334- sortItem . __real_value = dataItem
337+ ( sortItem as unknown as Record < string , any > ) . __real_value = dataItem
335338 } else {
336339 sortItem = {
337340 ...sortData [ sortKey ]
@@ -375,11 +378,13 @@ const getComponents = (mode, isSort = true) => {
375378 * 获取模块项的模块
376379 * @param {String } componentName 组件名称(大写,例如:img-preview)
377380 * @param {Oject } newObj 新增对象
378- * @param {Boolean } isMobile 是否为移动组件
379381 * @returns 模块对象
380382 */
381- export const addModule = ( { componentName, templateName, newObj = { } , isMobile = false } ) => {
382- const isEntry = templateName . endsWith ( 'index' )
383+ export const addModule = (
384+ { componentName, templateName, newObj = { } } :
385+ { componentName : string ; templateName ?: string ; newObj ?: object ; isMobile : boolean }
386+ ) => {
387+ const isEntry = templateName ?. endsWith ( 'index' ) ?? false
383388 return {
384389 path : `vue/src/${ componentName } /` + ( isEntry ? `${ templateName } .ts` : `src/${ templateName } .vue` ) ,
385390 type : isEntry ? 'component' : 'template' ,
0 commit comments