Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(api-surface): drop ambient built-in members from the surface snapshot

yhhb4bbb3419801
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index d79a8c946..889b206d6 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -3367,10 +3367,7 @@ toVersion: string
## MissingAssetsError — class
```
-message: string
missing: MissingAsset[]
-name: string
-stack: string | undefined
static new (missing: MissingAsset[]): MissingAssetsError
static prototype: MissingAssetsError
```
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index bfbbe6137..37f1980f3 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -3362,10 +3362,7 @@ toVersion: string
## MissingAssetsError — class
```
-message: string
missing: MissingAsset[]
-name: string
-stack: string | undefined
static new (missing: MissingAsset[]): MissingAssetsError
static prototype: MissingAssetsError
```
diff --git a/tools/api-surface.mjs b/tools/api-surface.mjs
index 5d969ba05..884451b22 100644
--- a/tools/api-surface.mjs
+++ b/tools/api-surface.mjs
@@ -109,6 +109,18 @@ function releaseTag(symbol) {
return 'stable';
}
+/** A member inherited from an ambient built-in (the TS lib or @types/node) — e.g. an
+ * `extends Error` class's `message`/`stack`, or `captureStackTrace` on ErrorConstructor.
+ * Its declaration lives in node_modules, so it floats with the installed @types version
+ * (this is what drifted CI: a newer @types/node augments ErrorConstructor). It is not the
+ * SDK's authored surface, so drop it. An SDK-authored override keeps at least one
+ * declaration outside node_modules and therefore survives. */
+function isAmbientMember(member) {
+ const decls = member.declarations;
+ if (!decls || decls.length === 0) return false;
+ return decls.every((d) => d.getSourceFile().fileName.replace(/\\/g, '/').includes('/node_modules/'));
+}
+
function isPrivateMember(member) {
if (member.escapedName?.toString().startsWith('__')) return true;
for (const decl of member.declarations ?? []) {
@@ -131,6 +143,7 @@ function memberLines(type, location) {
}
for (const member of type.getProperties()) {
if (isPrivateMember(member)) continue;
+ if (isAmbientMember(member)) continue;
const memberType = checker.getTypeOfSymbolAtLocation(member, location);
lines.push(`${member.name}: ${normalizeType(checker.typeToString(memberType, location, FMT))}`);
}