Add typings modules to match UMD modules. (#3821)

* Add typings modules to match UMD modules.
This commit is contained in:
Sam El-Husseini
2020-04-15 09:44:25 -07:00
committed by GitHub
parent c740d2781c
commit 7e4e6c7286
106 changed files with 2046 additions and 6 deletions

View File

@@ -365,7 +365,7 @@ function packageReadme() {
* The bundled declaration file is referenced in package.json in the types property.
*/
function packageDTS() {
return gulp.src('./typings/blockly.d.ts')
return gulp.src(['./typings/*.d.ts', './typings/msg/*.d.ts'], {base: './typings'})
.pipe(gulp.dest(`${packageDistribution}`));
};

View File

@@ -62,8 +62,8 @@ function typings() {
});
const srcs = [
'typings/parts/blockly-header.d.ts',
'typings/parts/blockly-interfaces.d.ts',
'typings/templates/blockly-header.template',
'typings/templates/blockly-interfaces.template',
`${tmpDir}/core/**`,
`${tmpDir}/core/components/**`,
`${tmpDir}/core/components/tree/**`,
@@ -86,6 +86,19 @@ function typings() {
});
};
// Generates the TypeScript definition files (d.ts) for Blockly locales.
function msgTypings(cb) {
const template = fs.readFileSync(path.join('typings/templates/msg.template'), 'utf-8');
const msgFiles = fs.readdirSync(path.join('msg', 'json'));
msgFiles.forEach(msg => {
const localeName = msg.substring(0, msg.indexOf('.json'));
const msgTypings = template.slice().replace(/<%= locale %>/gi, localeName);
fs.writeFileSync(path.join('typings', 'msg', localeName + '.d.ts'), msgTypings, 'utf-8');
})
cb();
}
module.exports = {
typings: typings
typings: typings,
msgTypings: msgTypings
};