Skip to content

Commit

Permalink
Update to typescript 5.7.3 (#16065)
Browse files Browse the repository at this point in the history
* Update to typescript 5.7.3

* update tspatch

* Addressing feedback
  • Loading branch information
RaananW authored Jan 15, 2025
1 parent 2d22c05 commit d248668
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 530 deletions.
571 changes: 73 additions & 498 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"selenium-webdriver": "^4.3.1",
"ts-jest": "~29.1.0",
"ts-node": "~10.9.0",
"ts-patch": "3.2.1",
"ts-patch": "3.3.0",
"tslib": "^2.4.0",
"typedoc": "^0.26.11",
"typescript": "~5.5.0",
"typedoc": "^0.27.6",
"typescript": "~5.7.0",
"webpack": "^5.73.0",
"webpack-cli": "^5.1.0"
},
Expand Down Expand Up @@ -89,7 +89,7 @@
"test:performance": "playwright test -c ./playwright.config.ts --project=performance",
"test:interactions": "playwright test -c ./playwright.config.ts --project=interaction",
"test:escheck": "nx run-many --target=test:escheck --parallel --maxParallel=6",
"test:docs": "node ./scripts/typedoc-generator.js",
"test:docs": "node ./scripts/typedoc-generator.mjs",
"prepare": "ts-patch install -s && npm run build:tools && npm i @dev/build-tools -D && npm run build:assets && npm run build:test-tools",
"clean": "npx nx run-many --target=clean --all && npm run build:tools",
"format": "npm run format:check && npm run format:fix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ export class SubSurfaceBlock extends NodeMaterialBlock {
, ${worldPosVarName}.xyz
, viewDirectionW
, ${refractionView}
, ${(isWebGPU ? "uniforms." : "") + refractionBlock?._vRefractionInfosName ?? ""}
, ${(isWebGPU ? "uniforms." : "") + refractionBlock?._refractionMatrixName ?? ""}
, ${(isWebGPU ? "uniforms." : "") + refractionBlock?._vRefractionMicrosurfaceInfosName ?? ""}
, ${(isWebGPU ? "uniforms." : "") + (refractionBlock?._vRefractionInfosName ?? "")}
, ${(isWebGPU ? "uniforms." : "") + (refractionBlock?._refractionMatrixName ?? "")}
, ${(isWebGPU ? "uniforms." : "") + (refractionBlock?._vRefractionMicrosurfaceInfosName ?? "")}
, ${isWebGPU ? "uniforms." : ""}vLightingIntensity
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
, alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ export function DecodeMesh(
const ptr = decoderModule._malloc(byteLength);
try {
decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);
const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);
// this cast seems to be needed because of an issue with typescript, as all constructors do have the ptr and numValues arguments.
const data = new (info.typedArrayConstructor as Float32ArrayConstructor)(info.heap.buffer, ptr, numValues);
onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);
} finally {
decoderModule._free(ptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class GreasedLineRibbonMesh extends GreasedLineBaseMesh {
}

const v: number[] = [1, 0, numOfPaths];
const doubleSided = options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED ?? false;
const doubleSided = options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED;

const closePath = options.ribbonOptions?.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_PATHS && options.ribbonOptions.closePath;
if (numOfPaths > 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class ToolsTabComponent extends PaneComponent {
const engine = scene.getEngine();

this._previousRenderingScale = engine.getHardwareScalingLevel();
engine.setHardwareScalingLevel(engine.getRenderWidth() / this._gifOptions.width ?? 1);
engine.setHardwareScalingLevel(engine.getRenderWidth() / this._gifOptions.width || 1);

const intervalId = setInterval(() => {
if (!this._gifRecorder) {
Expand Down
3 changes: 1 addition & 2 deletions packages/dev/serializers/src/glTF/2.0/glTFExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ export class GLTFExporter {

private _generateJSON(shouldUseGlb: boolean, bufferByteLength: number, fileName?: string, prettyPrint?: boolean): string {
const buffer: IBuffer = { byteLength: bufferByteLength };
let imageName: string;
let imageData: { data: ArrayBuffer; mimeType: ImageMimeType };
let bufferView: IBufferView;
let byteOffset: number = bufferByteLength;
Expand Down Expand Up @@ -496,7 +495,7 @@ export class GLTFExporter {
byteOffset += imageData.data.byteLength;
this._bufferViews.push(bufferView);
image.bufferView = this._bufferViews.length - 1;
image.name = imageName;
image.name = fileName;
image.mimeType = imageData.mimeType;
image.uri = undefined;
this._glTF.images!.push(image);
Expand Down
10 changes: 2 additions & 8 deletions scripts/comment-analyzer.js → scripts/comment-analyzer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ function checkCommentsOnChild(child, parent, namesToCheck = []) {
return errors.flat().filter((e) => e.result !== TestResultType.PASS);
}

/**
* Given a JSON data object, check for missing comments on public members.
* @param {*} data the JSON data that is output from typedoc
*/
module.exports = {
commentAnalyzer: function (data, namesToCheck = []) {
return checkCommentsOnChild(data, null, namesToCheck);
},
export const commentAnalyzer = (data, namesToCheck = []) => {
return checkCommentsOnChild(data, null, namesToCheck);
};
24 changes: 12 additions & 12 deletions scripts/typedoc-generator.js → scripts/typedoc-generator.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable no-console */
const TypeDoc = require("typedoc");
const fs = require("fs");
const glob = require("glob");
const { commentAnalyzer } = require("./comment-analyzer");
import { Application } from "typedoc";
import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
import { globSync } from "glob";
import { commentAnalyzer } from "./comment-analyzer.mjs";
// const { run } = require("jest");
const exec = require("child_process").exec;
import { exec } from "child_process";

function runCommand(command) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -34,7 +34,7 @@ function generateMessageFromError(error) {
}

async function generateTypedocAndAnalyze(entryPoints, filesChanged) {
const app = await TypeDoc.Application.bootstrapWithPlugins(
const app = await Application.bootstrapWithPlugins(
{
entryPoints,
skipErrorChecking: true,
Expand All @@ -60,7 +60,7 @@ async function generateTypedocAndAnalyze(entryPoints, filesChanged) {
const outputDir = "tmp";
await app.generateJson(project, `${outputDir}/typedoc.json`);

const data = JSON.parse(fs.readFileSync(`${outputDir}/typedoc.json`, "utf8"));
const data = JSON.parse(readFileSync(`${outputDir}/typedoc.json`, "utf8"));
console.log("Analyzing...");
const msgs = commentAnalyzer(data);
// check if the message is in one of the files that has been changed
Expand All @@ -81,14 +81,14 @@ async function main() {
const packages = process.argv.includes("--packages") ? process.argv[process.argv.indexOf("--packages") + 1].split(",") : ["core", "loaders", "materials", "gui", "serializers"];
const full = process.argv.includes("--full");
const filesChanged = (await runCommand(process.env.GIT_CHANGES_COMMAND || "git diff --name-only master")).split("\n");
const files = glob.globSync(`packages/dev/@(${packages.join("|")})/src/index.ts`).filter((f) => /*!f.endsWith("index.ts") && */ !f.endsWith(".d.ts"));
const files = globSync(`packages/dev/@(${packages.join("|")})/src/index.ts`).filter((f) => /*!f.endsWith("index.ts") && */ !f.endsWith(".d.ts"));
console.log(files);
const dirList = files.filter((file) => {
return file.endsWith(".ts");
});

if (!fs.existsSync("tmp")) {
fs.mkdirSync("tmp");
if (!existsSync("tmp")) {
mkdirSync("tmp");
}

await generateTypedocAndAnalyze(dirList, full ? undefined : filesChanged);
Expand All @@ -110,13 +110,13 @@ async function main() {
.join("\n")}
</testsuite>
</testsuites>`;
fs.writeFileSync("junit.xml", xml);
writeFileSync("junit.xml", xml);
// if in CI, save to errors.txt
if (process.env.CI) {
const messages = Object.keys(warnings)
.map((w) => `${w} ${generateMessageFromError(Object.keys(warnings)[w])}`)
.join("\n");
fs.writeFileSync("errors.txt", messages);
writeFileSync("errors.txt", messages);
// log to the console
console.log(`
Found ${Object.keys(warnings).length} typedoc errors:
Expand Down

0 comments on commit d248668

Please sign in to comment.