MCPcopy
hub / github.com/CesiumGS/cesium / createTypeScriptDefinitions

Function createTypeScriptDefinitions

gulpfile.js:1159–1208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1157}
1158
1159function createTypeScriptDefinitions() {
1160 // Run jsdoc with tsd-jsdoc to generate an initial Cesium.d.ts file.
1161 execSync("npx jsdoc --configure Tools/jsdoc/ts-conf.json", {
1162 stdio: "inherit",
1163 });
1164
1165 let source = readFileSync("Source/Cesium.d.ts").toString();
1166 source = processTypescriptSource("Source/Cesium.d.ts", source);
1167
1168 // The next step is to find the list of Cesium modules exported by the Cesium API
1169 // So that we can map these modules with a link back to their original source file.
1170
1171 const regex = /^declare (function|class|namespace|enum) (.+)/gm;
1172 let matches;
1173 const publicModules = new Set();
1174
1175 while ((matches = regex.exec(source))) {
1176 const moduleName = matches[2].match(/([^<\s|\(]+)/);
1177 publicModules.add(moduleName[1]);
1178 }
1179
1180 // Math shows up as "Math" because of it's aliasing from CesiumMath and namespace collision with actual Math
1181 // It fails the above regex so just add it directly here.
1182 publicModules.add("Math");
1183
1184 source = fixTypescriptDefinitionsSource(source);
1185
1186 // Wrap the source to actually be inside of a declared cesium module
1187 // and add any workaround and private utility types.
1188 source = `declare module "cesium" {
1189${source}
1190}
1191
1192`;
1193
1194 // Write the final source file back out
1195 writeFileSync("Source/Cesium.d.ts", source);
1196
1197 // Use tsc to compile it and make sure it is valid
1198 execSync("npx tsc -p Tools/jsdoc/tsconfig.json", {
1199 stdio: "inherit",
1200 });
1201
1202 // Also compile our smokescreen to make sure interfaces work as expected.
1203 execSync("npx tsc -p Specs/TypeScript/tsconfig.json", {
1204 stdio: "inherit",
1205 });
1206
1207 return Promise.resolve();
1208}
1209
1210/**
1211 * Reads `ThirdParty.extra.json` file

Callers 1

buildTsFunction · 0.85

Calls 4

processTypescriptSourceFunction · 0.85
toStringMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…