1
0
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:
mrholek
2019-11-10 15:47:54 +01:00
parent 48ab4394ce
commit 5cd192c303
2629 changed files with 7248 additions and 6069 deletions

View File

@@ -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
}