diff --git a/packages/core-math/.gitignore b/packages/core-math/.gitignore index 8ca1d8480e2..8f302ffb71f 100644 --- a/packages/core-math/.gitignore +++ b/packages/core-math/.gitignore @@ -1,5 +1,6 @@ index.js index.d.ts +index.tsc.d.ts Build Specs/SpecList.js docs diff --git a/packages/core-math/Source/Cartesian2.js b/packages/core-math/Source/Cartesian2.js index fb17895c89d..859ebfbd0c4 100644 --- a/packages/core-math/Source/Cartesian2.js +++ b/packages/core-math/Source/Cartesian2.js @@ -1,6 +1,9 @@ import { Check, defined, DeveloperError } from "@cesium/core-utils"; import CesiumMath from "./Math.js"; +/** @ignore @typedef {import('./Cartesian3.js')} Cartesian3 */ +/** @ignore @typedef {import('./Cartesian4.js')} Cartesian4 */ + /** * A 2D Cartesian point. * @alias Cartesian2 diff --git a/packages/core-math/Source/Cartesian4.js b/packages/core-math/Source/Cartesian4.js index 20f09b14b43..dea7379ac65 100644 --- a/packages/core-math/Source/Cartesian4.js +++ b/packages/core-math/Source/Cartesian4.js @@ -1,6 +1,8 @@ import { Check, defined, DeveloperError } from "@cesium/core-utils"; import CesiumMath from "./Math.js"; +/** @ignore @typedef {import('@cesium/engine').Color} Color */ + /** * A 4D Cartesian point. * @alias Cartesian4 diff --git a/packages/core-math/Source/Matrix4.js b/packages/core-math/Source/Matrix4.js index 01ed4885656..c1ba76f3535 100644 --- a/packages/core-math/Source/Matrix4.js +++ b/packages/core-math/Source/Matrix4.js @@ -10,6 +10,10 @@ import { import CesiumMath from "./Math.js"; import Matrix3 from "./Matrix3.js"; +/** @ignore @typedef {import('@cesium/engine').Camera} Camera */ +/** @ignore @typedef {import('@cesium/engine').TranslationRotationScale} TranslationRotationScale */ +/** @ignore @typedef {import('@cesium/engine').Quaternion} Quaternion */ + /** * A 4x4 matrix, indexable as a column-major order array. * Constructor parameters are in row-major order for code readability. diff --git a/packages/core-math/package.json b/packages/core-math/package.json index d04a7b46bd9..dc811f12660 100644 --- a/packages/core-math/package.json +++ b/packages/core-math/package.json @@ -37,6 +37,7 @@ "scripts": { "build": "gulp build --workspace @cesium/core-math", "build-ts": "gulp buildTs --workspace @cesium/core-math", + "build-tsc": "tsc --checkJs false", "coverage": "gulp coverage --workspace @cesium/core-math", "test": "gulp test --workspace @cesium/core-math", "postversion": "gulp postversion --workspace @cesium/core-math", diff --git a/packages/core-math/tsconfig.json b/packages/core-math/tsconfig.json index ecec403985b..86fa5a86503 100644 --- a/packages/core-math/tsconfig.json +++ b/packages/core-math/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["index.js", "Source/**/*.js"], + "include": ["Source/**/*.js"], "compilerOptions": { // module configuration "moduleResolution": "bundler", @@ -7,8 +7,14 @@ "target": "ES2022", // i/o - "noEmit": true, + "declaration": true, + "declarationDir": "Build/Types", + "emitDeclarationOnly": true, "allowJs": true, - "checkJs": true + "checkJs": true, + + // ignore type definitions in other modules for now, we need types + // to be correct and to resolve imports first. + "skipLibCheck": true } } diff --git a/packages/core-utils/.gitignore b/packages/core-utils/.gitignore index 8ca1d8480e2..8f302ffb71f 100644 --- a/packages/core-utils/.gitignore +++ b/packages/core-utils/.gitignore @@ -1,5 +1,6 @@ index.js index.d.ts +index.tsc.d.ts Build Specs/SpecList.js docs diff --git a/packages/core-utils/package.json b/packages/core-utils/package.json index d5f5c80dc29..bd81f154cd2 100644 --- a/packages/core-utils/package.json +++ b/packages/core-utils/package.json @@ -35,6 +35,7 @@ "scripts": { "build": "gulp build --workspace @cesium/core-utils", "build-ts": "gulp buildTs --workspace @cesium/core-utils", + "build-tsc": "tsc --checkJs false", "build-docs": "typedoc ./index.js --skipErrorChecking", "coverage": "gulp coverage --workspace @cesium/core-utils", "test": "gulp test --workspace @cesium/core-utils", diff --git a/packages/core-utils/tsconfig.json b/packages/core-utils/tsconfig.json index ecec403985b..86fa5a86503 100644 --- a/packages/core-utils/tsconfig.json +++ b/packages/core-utils/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["index.js", "Source/**/*.js"], + "include": ["Source/**/*.js"], "compilerOptions": { // module configuration "moduleResolution": "bundler", @@ -7,8 +7,14 @@ "target": "ES2022", // i/o - "noEmit": true, + "declaration": true, + "declarationDir": "Build/Types", + "emitDeclarationOnly": true, "allowJs": true, - "checkJs": true + "checkJs": true, + + // ignore type definitions in other modules for now, we need types + // to be correct and to resolve imports first. + "skipLibCheck": true } } diff --git a/scripts/build.js b/scripts/build.js index 46704e11677..c466edb9b3b 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -916,6 +916,7 @@ export async function bundleTestWorkers(options) { export async function createIndexJs(workspace) { const version = await getVersion(); let contents = `globalThis.CESIUM_VERSION = "${version}";\n`; + let contentsDts = ""; // Re-export core-utils and core-math types for backwards compatibility in engine package if (workspace === "engine") { @@ -937,6 +938,7 @@ export async function createIndexJs(workspace) { let moduleId = file; moduleId = filePathToModuleId(moduleId); + const moduleTypesId = moduleId.replace("Source", "Build/Types"); // Rename shader files, such that ViewportQuadFS.glsl is exported as _shadersViewportQuadFS in JS. @@ -946,6 +948,7 @@ export async function createIndexJs(workspace) { } assignmentName = assignmentName.replace(/(\.|-)/g, "_"); contents += `export { default as ${assignmentName} } from './${moduleId}.js';${EOL}`; + contentsDts += `export { default as ${assignmentName} } from './${moduleTypesId}.js';${EOL}`; // TODO(donmccurdy): Why is this needed? if (assignmentName === "Math") { @@ -957,6 +960,12 @@ export async function createIndexJs(workspace) { encoding: "utf-8", }); + if (workspace === "core-math" || workspace === "core-utils") { + await writeFile(`packages/${workspace}/index.tsc.d.ts`, contentsDts, { + encoding: "utf-8", + }); + } + return contents; }