microsoft / microsoft/TypeScript

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

Ouverte
#63,838 1 commentaire 1 réaction 2 personnes assignées Voir sur GitHub

@andrewbranch y travaille déjà.

Depuis le 16/6/2026.

Needs Investigation
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

## 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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.