mirror of
https://github.com/coreui/coreui-icons.git
synced 2025-08-29 02:59:49 +02:00
feat: add typings
This commit is contained in:
@@ -52,7 +52,7 @@ dirnames.forEach(setName => {
|
||||
)
|
||||
fs.writeFile(
|
||||
`js/${setName}/${tsFilename}`,
|
||||
`export const ${importName}: string[];`,
|
||||
`export declare const ${importName}: string[];`,
|
||||
() => ''
|
||||
)
|
||||
})
|
||||
@@ -63,11 +63,21 @@ dirnames.forEach(setName => {
|
||||
`export const ${setName}Set = ` + JSON.stringify(contents),
|
||||
() => ''
|
||||
)
|
||||
fs.writeFile(
|
||||
`js/${setName}/${setName}-set.d.ts`,
|
||||
typings(names, setName, false),
|
||||
() => ''
|
||||
)
|
||||
fs.writeFile(
|
||||
`js/${setName}/index.js`,
|
||||
getImports(names, setName),
|
||||
() => ''
|
||||
)
|
||||
fs.writeFile(
|
||||
`js/${setName}/index.d.ts`,
|
||||
typings(names, setName),
|
||||
() => ''
|
||||
)
|
||||
allNames[setName] = names
|
||||
}, 1000)
|
||||
})
|
||||
@@ -136,3 +146,17 @@ function getImports(names, setName, deep = false) {
|
||||
}).join('\n')
|
||||
return defaultImport + defaultExport + importString + '\n' + exportString
|
||||
}
|
||||
|
||||
function typings(names, setName, all = true) {
|
||||
|
||||
const icons = names.map(name => {
|
||||
return ` "${name.importName}": string[];`
|
||||
}).join('\n')
|
||||
const set = `export declare const ${setName}Set: {\n${icons}\n}`
|
||||
|
||||
const exportString = names.map(name => {
|
||||
return `export declare const ${name.importName}: string[];`
|
||||
}).join('\n')
|
||||
|
||||
return all ? set + '\n' + exportString : set
|
||||
}
|
||||
|
Reference in New Issue
Block a user