CodeSampleX

Ejemplo

@typescript-eslint/typescript-estree 8.65.0: parseAndGenerateServices

Muestra verificada para npm @typescript-eslint/typescript-estree 8.65.0: parseAndGenerateServices. El contrato se ejecutó en node 22 · linux alpine/x64 …

sha256:c38cb55c5e9b741b53977b06dbd8717e36327812c96732aeed16789dbfd465c7

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-29

Caso

HOW
Objetivo
verify parseAndGenerateServices in pkg:npm/%40typescript-eslint/typescript-estree@8.65.0
Paquetes
Símbolos
  • parseAndGenerateServices
Entorno
node 22.23.2
Creado
2026-08-29T05:50:12Z

Contrato

  1. parseAndGenerateServices parses TypeScript source into ESTree AST and returns services with bidirectional node maps
  2. esTreeNodeToTSNodeMap and tsNodeToESTreeNodeMap provide reciprocal mappings between ESTree and TypeScript AST nodes
  3. parseAndGenerateServices supports JSX and TSX syntax with jsx option enabled
  4. parseAndGenerateServices throws TSError on malformed TypeScript syntax
  5. parseAndGenerateServices preserves comments and tokens when options are enabled

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.cjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify parseAndGenerateServices in pkg:npm/%40typescript-eslint/typescript-estree@8.65.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40typescript-eslint/typescript-estree@8.65.0
Demonstrate these symbols/APIs:
  - parseAndGenerateServices
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.6
  - runtime: go@1.26.6

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:9d4db80792d7cb687ca01b646f392f198df0ef7c2252c0281c1a3b611c49f87f","constraints":{"executionContext":"node"},"contract":["parseAndGenerateServices parses TypeScript source into ESTree AST and returns services with bidirectional node maps","esTreeNodeToTSNodeMap and tsNodeToESTreeNodeMap provide reciprocal mappings between ESTree and TypeScript AST nodes","parseAndGenerateServices supports JSX and TSX syntax with jsx option enabled","parseAndGenerateServices throws TSError on malformed TypeScript syntax","parseAndGenerateServices preserves comments and tokens when options are enabled"],"goal":"verify parseAndGenerateServices in pkg:npm/%40typescript-eslint/typescript-estree@8.65.0","kind":"HOW","packages":["pkg:npm/%40typescript-eslint/typescript-estree@8.65.0"],"schemaVersion":1,"symbols":["parseAndGenerateServices"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40typescript-eslint/typescript-estree@8.65.0"],"schemaVersion":1,"subject":"pkg:npm/%40typescript-eslint/typescript-estree@8.65.0","symbols":["parseAndGenerateServices"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-typescript-estree-parse-and-generate-services",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-typescript-estree-parse-and-generate-services",
      "version": "1.0.0",
      "dependencies": {
        "@typescript-eslint/typescript-estree": "8.65.0"
      }
    },
    "node_modules/@typescript-eslint/project-service": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.65.0.tgz",
      "integrity": "sha512-SxnPhbTsGahizDgbu7oqFH/xVtzIqMd/s+WtnSxNxJZJpLbdT5IPdzg8EZxO3+PoKahXmwJLeNQOpKJb3/bi7Q==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/tsconfig-utils": "^8.65.0",
        "@typescript-eslint/types": "^8.65.0",
        "debug": "^4.4.3"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4 <6.1.0"
      }
    },
    "node_modules/@typescript-eslint/tsconfig-utils": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.65.0.tgz",
      "integrity": "sha512-j6GzGqCiRdA7Qhur2VVmKZAkBLfnHFQfx4TaJGL9RMveZqCo48jSHHO0DTgizEnGhtWnqmbtCUSrqSkdiY/0Hg==",
      "license": "MIT",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4 <6.1.0"
      }
    },
    "node_modules/@typescript-eslint/types": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.65.0.tgz",
      "integrity": "sha512-JSSwWNy+H0E/01jJEM+hrX6N0OFDzFzeIhHFSAS01tlVaevpG8cFyYRPhS5yjGOvBUx3sqQHVMjCL1CAZZMxBg==",
      "license": "MIT",
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    },
    "node_modules/@typescript-eslint/typescript-estree": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.65.0.tgz",
      "integrity": "sha512-JboAE2swaYt4tb1fHhHTABE2K+OLy09XfcTbhnk4Pw96f9dd2e9iYsJ28gBggHlo5z5x1rkyWvcPoTuNTd4oGg==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/project-service": "8.65.0",
        "@typescript-eslint/tsconfig-utils": "8.65.0",
        "@typescript-eslint/types": "8.65.0",
        "@typescript-eslint/visitor-keys": "8.65.0",
        "debug": "^4.4.3",
        "minimatch": "^10.2.2",
        "semver": "^7.7.3",
        "tinyglobby": "^0.2.15",
        "ts-api-utils": "^2.5.0"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4 <6.1.0"
      }
    },
    "node_modules/@typescript-eslint/visitor-keys": {
      "version": "8.65.0",
      "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.65.0.tgz",
      "integrity": "sha512-8C71BQkGjiMmXtop7pHVJu1l2NNShFdkCyD6a2ezzs5vU/L3LRtb69EtcteFwz0mYMPzIgOw0n6OV4VBUWZd7A==",
      "license": "MIT",
      "dependencies": {
        "@typescript-eslint/types": "8.65.0",
        "eslint-visitor-keys": "^5.0.0"
      },
      "engines": {
        "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/typescript-eslint"
      }
    },
    "node_modules/balanced-match": {
      "version": "4.0.4",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
      "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
      "license": "MIT",
      "engines": {
        "node": "18 || 20 || >=22"
      }
    },
    "node_modules/brace-expansion": {
      "version": "5.0.9",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
      "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^4.0.2"
      },
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/eslint-visitor-keys": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz",
      "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==",
      "license": "Apache-2.0",
      "engines": {
        "node": "^20.19.0 || ^22.13.0 || >=24"
      },
      "funding": {
        "url": "https://opencollective.com/eslint"
      }
    },
    "node_modules/fdir": {
      "version": "6.5.0",
      "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
      "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
      "license": "MIT",
      "engines": {
        "node": ">=12.0.0"
      },
      "peerDependencies": {
        "picomatch": "^3 || ^4"
      },
      "peerDependenciesMeta": {
        "picomatch": {
          "optional": true
        }
      }
    },
    "node_modules/minimatch": {
      "version": "10.2.6",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
      "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
      "license": "BlueOak-1.0.0",
      "dependencies": {
        "brace-expansion": "^5.0.8"
      },
      "engines": {
        "node": "18 || 20 || >=22"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/picomatch": {
      "version": "4.0.7",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
      "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    },
    "node_modules/semver": {
      "version": "7.8.5",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
      "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/tinyglobby": {
      "version": "0.2.17",
      "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
      "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
      "license": "MIT",
      "dependencies": {
        "fdir": "^6.5.0",
        "picomatch": "^4.0.4"
      },
      "engines": {
        "node": ">=12.0.0"
      },
      "funding": {
        "url": "https://github.com/sponsors/SuperchupuDev"
      }
    },
    "node_modules/ts-api-utils": {
      "version": "2.5.0",
      "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
      "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==",
      "license": "MIT",
      "engines": {
        "node": ">=18.12"
      },
      "peerDependencies": {
        "typescript": ">=4.8.4"
      }
    },
    "node_modules/typescript": {
      "version": "6.0.3",
      "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
      "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
      "license": "Apache-2.0",
      "peer": true,
      "bin": {
        "tsc": "bin/tsc",
        "tsserver": "bin/tsserver"
      },
      "engines": {
        "node": ">=14.17"
      }
    }
  }
}
package.json
{
  "name": "verify-typescript-estree-parse-and-generate-services",
  "version": "1.0.0",
  "private": true,
  "description": "verify parseAndGenerateServices in pkg:npm/@typescript-eslint/typescript-estree@8.65.0",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@typescript-eslint/typescript-estree": "8.65.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify parseAndGenerateServices in pkg:npm/%40typescript-eslint/typescript-estree@8.65.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40typescript-eslint/typescript-estree@8.65.0"
  ],
  "symbols": [
    "parseAndGenerateServices"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const { parseAndGenerateServices } = require('@typescript-eslint/typescript-estree');

/**
 * Parses TypeScript source code into an ESTree AST and generates parser services.
 *
 * @param {string} code - TypeScript source code
 * @param {object} [options={}] - Parser options
 * @returns {{ ast: object, services: object }}
 */
function parseTypeScriptWithServices(code, options = {}) {
  return parseAndGenerateServices(code, options);
}

/**
 * Retrieves the corresponding TypeScript compiler AST node for an ESTree node.
 *
 * @param {object} services - Services object returned by parseAndGenerateServices
 * @param {object} estreeNode - ESTree AST node
 * @returns {object|undefined}
 */
function getCorrespondingTSNode(services, estreeNode) {
  if (!services || !services.esTreeNodeToTSNodeMap) {
    return undefined;
  }
  return services.esTreeNodeToTSNodeMap.get(estreeNode);
}

/**
 * Retrieves the corresponding ESTree AST node for a TypeScript compiler AST node.
 *
 * @param {object} services - Services object returned by parseAndGenerateServices
 * @param {object} tsNode - TypeScript AST node
 * @returns {object|undefined}
 */
function getCorrespondingESTreeNode(services, tsNode) {
  if (!services || !services.tsNodeToESTreeNodeMap) {
    return undefined;
  }
  return services.tsNodeToESTreeNodeMap.get(tsNode);
}

/**
 * Parses TSX / JSX source code with services.
 *
 * @param {string} code - TSX source code
 * @param {object} [options={}] - Additional parser options
 * @returns {{ ast: object, services: object }}
 */
function parseTSXWithServices(code, options = {}) {
  return parseAndGenerateServices(code, {
    jsx: true,
    ...options,
  });
}

module.exports = {
  parseTypeScriptWithServices,
  getCorrespondingTSNode,
  getCorrespondingESTreeNode,
  parseTSXWithServices,
};
test/contract.cjs
const assert = require('node:assert/strict');
const {
  parseAndGenerateServices,
  AST_NODE_TYPES,
  AST_TOKEN_TYPES,
  TSError,
} = require('@typescript-eslint/typescript-estree');
const {
  parseTypeScriptWithServices,
  getCorrespondingTSNode,
  getCorrespondingESTreeNode,
  parseTSXWithServices,
} = require('../src/index.js');

// 1. parseAndGenerateServices parses TypeScript source into ESTree AST and returns services with bidirectional node maps
const tsCode = `
// Greeter interface definition
interface User {
  id: number;
  name: string;
}

const greet = (user: User): string => {
  return "Hello, " + user.name;
};
`;

const result = parseTypeScriptWithServices(tsCode, {
  loc: true,
  range: true,
  tokens: true,
  comment: true,
});

assert.ok(result, 'Result should be defined');
assert.strictEqual(result.ast.type, AST_NODE_TYPES.Program);
assert.strictEqual(result.ast.body.length, 2);
assert.strictEqual(result.ast.body[0].type, AST_NODE_TYPES.TSInterfaceDeclaration);
assert.strictEqual(result.ast.body[1].type, AST_NODE_TYPES.VariableDeclaration);
assert.ok(result.services, 'Services object should exist');
assert.ok(result.services.esTreeNodeToTSNodeMap, 'esTreeNodeToTSNodeMap should exist');
assert.ok(result.services.tsNodeToESTreeNodeMap, 'tsNodeToESTreeNodeMap should exist');

// 2. esTreeNodeToTSNodeMap and tsNodeToESTreeNodeMap provide reciprocal mappings between ESTree and TypeScript AST nodes
const interfaceNode = result.ast.body[0];
const tsInterfaceNode = getCorrespondingTSNode(result.services, interfaceNode);
assert.ok(tsInterfaceNode, 'TypeScript AST node should be resolved for interface');
const roundtrippedEstreeNode = getCorrespondingESTreeNode(result.services, tsInterfaceNode);
assert.strictEqual(
  roundtrippedEstreeNode,
  interfaceNode,
  'Mapping from TS node back to ESTree node should return the exact same node instance'
);

const varDeclNode = result.ast.body[1];
const tsVarDeclNode = getCorrespondingTSNode(result.services, varDeclNode);
assert.ok(tsVarDeclNode, 'TypeScript AST node should be resolved for variable declaration');
const roundtrippedVarDecl = getCorrespondingESTreeNode(result.services, tsVarDeclNode);
assert.strictEqual(
  roundtrippedVarDecl,
  varDeclNode,
  'Mapping from TS var declaration node back to ESTree node should match'
);

// 3. parseAndGenerateServices supports JSX and TSX syntax with jsx option enabled
const tsxCode = `
const Card = ({ title, count }: { title: string; count: number }) => {
  return (
    <div className="card-container">
      <h2 className="title">{title}</h2>
      <span className="count">{count}</span>
    </div>
  );
};
`;

const tsxResult = parseTSXWithServices(tsxCode, {
  loc: true,
  range: true,
});

assert.strictEqual(tsxResult.ast.type, AST_NODE_TYPES.Program);
const funcComponent = tsxResult.ast.body[0].declarations[0].init;
assert.strictEqual(funcComponent.type, AST_NODE_TYPES.ArrowFunctionExpression);
const returnStatement = funcComponent.body.body[0];
assert.strictEqual(returnStatement.type, AST_NODE_TYPES.ReturnStatement);
assert.strictEqual(returnStatement.argument.type, AST_NODE_TYPES.JSXElement);
assert.strictEqual(
  returnStatement.argument.openingElement.name.name,
  'div'
);

// 4. parseAndGenerateServices throws TSError on malformed TypeScript syntax
let caughtError = null;
try {
  parseAndGenerateServices('const invalid :::: syntax = ;', {});
} catch (err) {
  caughtError = err;
}

assert.ok(caughtError, 'Should throw an error on syntax violation');
assert.strictEqual(
  caughtError.name,
  'TSError',
  'Error thrown on invalid TS syntax should be a TSError'
);
assert.ok(
  caughtError.lineNumber !== undefined || caughtError.index !== undefined,
  'TSError should contain line or index location information'
);

// 5. parseAndGenerateServices preserves comments and tokens when options are enabled
assert.ok(Array.isArray(result.ast.comments), 'AST should include comments array');
assert.strictEqual(result.ast.comments.length, 1);
assert.strictEqual(
  result.ast.comments[0].value.trim(),
  'Greeter interface definition'
);

assert.ok(Array.isArray(result.ast.tokens), 'AST should include tokens array');
assert.ok(
  result.ast.tokens.some(
    (t) => t.type === AST_TOKEN_TYPES.Identifier && t.value === 'greet'
  ),
  'Tokens array should contain the greet identifier token'
);
assert.ok(
  result.ast.tokens.some(
    (t) => t.type === AST_TOKEN_TYPES.Keyword && t.value === 'const'
  ),
  'Tokens array should contain keyword tokens'
);

console.log('All contract assertions passed successfully.');

Seeder de origen

anónimo