microsoft / microsoft/TypeScript

RemoteNodeList inherited array methods throw this.view.getUint32 is not a function

Đang mở
#63,838 1 bình luận 1 reaction 2 người được giao Xem trên GitHub

@andrewbranch đang làm issue này rồi.

Từ ngày 16/6/2026.

Needs Investigation
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

## Steps to reproduce

Using `@typescript/native-preview@7.0.0-dev.20260616.1` and Node `v24.11.1`:

1. Create a minimal project and install native-preview:

```sh
mkdir tsgo-remote-node-list-filter
cd tsgo-remote-node-list-filter
npm init -y
npm install @typescript/native-preview@7.0.0-dev.20260616.1
```

2. Save this as `repro.mjs`:

```js
import fs from "node:fs";
import os from "node:os";
import path from "node:path";

import { API } from "@typescript/native-preview/unstable/sync";

const source = `interface A {}
interface B {}
`;

const directory = fs.mkdtempSync(path.join(os.tmpdir(), "tsgo-remote-node-list-filter-"));
fs.writeFileSync(
path.join(directory, "tsconfig.json"),
JSON.stringify(
{
compilerOptions: {
module: "NodeNext",
moduleResolution: "NodeNext",
skipLibCheck: true,
strict: true,
target: "ES2022",
},
files: ["index.ts"],
},
null,
2
)
);
fs.writeFileSync(path.join(directory, "index.ts"), source);

const api = new API({ cwd: directory });

try {
const project = api.updateSnapshot({ openProject: "tsconfig.json" }).getProjects()[0];
const sourceFile = project.program.getSourceFile("index.ts");

console.log(`sourceFile.statements.length = ${sourceFile.statements.length}`);
console.log(sourceFile.statements.filter(() => true).length);
} finally {
api.close();
}
```

3. Run:

```sh
node repro.mjs
```

## Actual behavior

`sourceFile.statements.length` works, but `sourceFile.statements.filter(() => true)` throws:

```
sourceFile.statements.length = 2
Calling sourceFile.statements.filter(() => true)...
TypeError: this.view.getUint32 is not a function
at RemoteNodeList.get data (node_modules/@typescript/native-preview/src/api/node/node.generated.ts:58:26)
at new RemoteNodeList (node_modules/@typescript/native-preview/src/api/node/node.generated.ts:70:28)
at RemoteNodeList.filter ()
at (repro.mjs:35:43)
at ModuleJob.run (node:internal/modules/esm/module_job:377:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:671:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)
```

`sourceFile.statements.map(...)`, `sourceFile.statements.flatMap(...)`, and other inherited array methods appear to have the same issue.

## Expected behavior

The native AST declarations expose `NodeArray` as extending `ReadonlyArray`, so standard array methods are available at compile time. I would expect those methods to work, or for `NodeArray` not to expose inherited array methods that are unsafe to call.

Workaround: `Array.from(sourceFile.statements).filter(() => true)` works.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.