Skip to content

TypeScript

Last verified end to end: 2026-08-26 (query_code schema version 1).

For exact inbound and outbound symbol edges, proof tiers, and adapter-specific caveats, see Reference Traversal. For bounded allocation/factory provenance, ambiguity, exact member targets, and call-input composition, see Receiver Traversal.

TypeScript shares JavaScript’s structural adapter and adds interface, enum, abstract-class, type-alias, type-identifier, decorator, and TSX grammar shapes.

function Route(path: string) {
return (_target: unknown, _key: string) => path;
}
interface User {
id: UserId;
}
enum State {
Ready,
}
abstract class BaseService {}
type UserId = string;
class Service extends BaseService {
constructor() {
super();
}
@Route("/save")
save(value: string): string {
return value;
}
}
export const service = new Service();
function Input(_target: object, _key: string, _index: number) {}
class Controller {
handle(@Input value: string): string {
return value;
}
}
export const View = () => (
<button onClick={() => service.save("tsx")}>Save</button>
);
const props = { title: "Save" };
const dynamicKey = "tone";
const html = "safe";
const config = { __html: html, [dynamicKey]: "warm", ...props };
export const StructuredView = () => (
<div {...props} dangerouslySetInnerHTML={config}>
<span>{html}</span>
</div>
);

A type alias is a normalized declaration; interfaces, enums, and abstract classes are normalized as class.

(language typescript (declaration :name "UserId"))
{"languages":["typescript"],"match":{"kind":"declaration","name":"UserId"}}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/service.ts",
"language": "typescript",
"kind": "class",
"start_line": 14,
"end_line": 14,
"text": "type UserId = string;",
"enclosing_symbol": "service.ts.UserId"
}
],
"truncated": false
}
(language typescript (class (name/regex "^(User|State|BaseService)$")))
{
"languages": ["typescript"],
"match": {
"kind": "class",
"name": {"regex": "^(User|State|BaseService)$"}
}
}
{
"results": [
{"result_type":"structural_match","path":"typescript/service.ts","language":"typescript","kind":"class","start_line":5,"end_line":7,"text":"interface User {…","enclosing_symbol":"User"},
{"result_type":"structural_match","path":"typescript/service.ts","language":"typescript","kind":"class","start_line":9,"end_line":11,"text":"enum State {…","enclosing_symbol":"State"},
{"result_type":"structural_match","path":"typescript/service.ts","language":"typescript","kind":"class","start_line":13,"end_line":13,"text":"abstract class BaseService {}","enclosing_symbol":"BaseService"}
],
"truncated": false
}

callable includes functions, methods, constructors, and lambdas. not_kind keeps only the named save method, and the decorator constraint proves its annotation mapping.

(callable
:name "save"
(not-kind [constructor lambda])
:decorators [(decorator :name "Route" :capture "route")])
{
"match": {
"kind": "callable",
"name": "save",
"not_kind": ["constructor", "lambda"],
"decorators": [
{"kind": "decorator", "name": "Route", "capture": "route"}
]
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/service.ts",
"language": "typescript",
"kind": "method",
"start_line": 22,
"end_line": 24,
"text": "save(value: string): string {…",
"captures": [
{"name":"route","text":"@Route(\"/save\")","start_line":21}
],
"enclosing_symbol": "Service.save"
}
],
"truncated": false
}

Parameters are file-backed declarations with their own exact source ranges. A decorators constraint selects the parameter through its structural decorator edge instead of matching decorator text.

(language typescript
(parameter :name "value"
:decorators [(decorator :name "Input")]))
{
"languages": ["typescript"],
"match": {
"kind": "parameter",
"name": "value",
"decorators": [{"kind": "decorator", "name": "Input"}]
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/service.ts",
"language": "typescript",
"kind": "parameter",
"start_line": 32,
"end_line": 32,
"text": "@Input value: string",
"enclosing_symbol": "Controller.handle"
}
],
"truncated": false
}

The TypeScript language filter includes .tsx; where narrows this call to the TSX fixture and excludes the new Service() call in the .ts file.

(where "typescript/**/*.tsx"
(language typescript
(call :callee "save" :receiver "service" :args [(capture "value")])))
{
"where": ["typescript/**/*.tsx"],
"languages": ["typescript"],
"match": {
"kind": "call",
"callee": {"name": "save"},
"receiver": {"name": "service"},
"args": [{"capture": "value"}]
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/view.tsx",
"language": "typescript",
"kind": "call",
"start_line": 2,
"end_line": 2,
"text": "service.save(\"tsx\")",
"captures": [{"name":"value","text":"\"tsx\"","start_line":2}],
"enclosing_symbol": "View"
}
],
"truncated": false
}

JSX elements, named and spread attributes, and their exact value operands are structural facts. Tag, attribute, child, and value roles compose without parsing source text.

(language typescript
(jsx_element
:tag "div"
:attributes [
(jsx_spread_attribute :value "props")
(jsx_attribute :name "dangerouslySetInnerHTML" :value "config")
]
:children [(jsx_element :tag "span")]))
{
"languages": ["typescript"],
"match": {
"kind": "jsx_element",
"tag": {"name": "div"},
"attributes": [
{"kind": "jsx_spread_attribute", "value": {"name": "props"}},
{"kind": "jsx_attribute", "name": "dangerouslySetInnerHTML", "value": {"name": "config"}}
],
"children": [{"kind": "jsx_element", "tag": {"name": "span"}}]
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/jsx-structure.tsx",
"language": "typescript",
"kind": "jsx_element",
"start_line": 7,
"end_line": 9,
"text": "<div {...props} dangerouslySetInnerHTML={config}>…",
"enclosing_symbol": "StructuredView"
}
],
"truncated": false
}

Object properties expose structured key and value roles. Computed properties remain distinct from static keys, while spreads use the context-free spread_element kind in object, array, and argument contexts.

(language typescript (object_property :key "__html" :value "html"))
{
"languages": ["typescript"],
"match": {
"kind": "object_property",
"key": {"name": "__html"},
"value": {"name": "html"}
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/jsx-structure.tsx",
"language": "typescript",
"kind": "object_property",
"start_line": 4,
"end_line": 4,
"text": "__html: html",
"enclosing_symbol": "jsx-structure.tsx.config"
}
],
"truncated": false
}
(language typescript (computed_property :value "dynamicKey"))
{"languages":["typescript"],"match":{"kind":"computed_property","value":{"name":"dynamicKey"}}}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/jsx-structure.tsx",
"language": "typescript",
"kind": "computed_property",
"start_line": 4,
"end_line": 4,
"text": "[dynamicKey]",
"enclosing_symbol": "jsx-structure.tsx.config"
}
],
"truncated": false
}
(language typescript (spread_element :value "props"))
{"languages":["typescript"],"match":{"kind":"spread_element","value":{"name":"props"}}}
{
"results": [
{
"result_type": "structural_match",
"path": "typescript/jsx-structure.tsx",
"language": "typescript",
"kind": "spread_element",
"start_line": 4,
"end_line": 4,
"text": "...props",
"enclosing_symbol": "jsx-structure.tsx.config"
},
{
"result_type": "structural_match",
"path": "typescript/jsx-structure.tsx",
"language": "typescript",
"kind": "spread_element",
"start_line": 7,
"end_line": 7,
"text": "...props",
"enclosing_symbol": "StructuredView"
}
],
"truncated": false
}

Interfaces, enums, and abstract classes intentionally share the normalized class kind. Use name, containment, or source/path scoping when their source syntax matters; there is no separate public interface kind.

This example exposes bounded receiver values through the shared public query_code contract. The adapter preserves explicit unknown, ambiguous, unsupported, and budget outcomes; it does not provide whole-program points-to, general alias analysis, path-sensitive control flow, taint, or general data flow.

class QueryRoot {
rootMember(): void {}
}
class QueryLeaf extends QueryRoot {
leafMember(): void {}
}
(supertypes :transitive true (enclosing-decl (language typescript (class :name "QueryLeaf"))))
{"languages":["typescript"],"match":{"kind":"class","name":"QueryLeaf"},"steps":[{"op":"enclosing_decl"},{"op":"supertypes","transitive":true}]}
{
"results": [
{
"end_line": 3,
"fq_name": "QueryRoot",
"kind": "class",
"language": "typescript",
"path": "typescript/hierarchy.ts",
"provenance": [
{
"seed": {
"end_line": 7,
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "structural_match",
"start_line": 5
},
"steps": [
{
"op": "enclosing_decl",
"result": {
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "declaration",
"start_line": 5
}
},
{
"op": "supertypes",
"result": {
"end_line": 3,
"fq_name": "QueryRoot",
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "declaration",
"start_line": 1
}
}
]
}
],
"result_type": "declaration",
"signature": "class QueryRoot {",
"start_line": 1
}
],
"truncated": false
}
(owner (members (subtypes (enclosing-decl (language typescript (class :name "QueryRoot"))))))
{"languages":["typescript"],"match":{"kind":"class","name":"QueryRoot"},"steps":[{"op":"enclosing_decl"},{"op":"subtypes"},{"op":"members"},{"op":"owner"}]}
{
"results": [
{
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"language": "typescript",
"path": "typescript/hierarchy.ts",
"provenance": [
{
"seed": {
"end_line": 3,
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "structural_match",
"start_line": 1
},
"steps": [
{
"op": "enclosing_decl",
"result": {
"end_line": 3,
"fq_name": "QueryRoot",
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "declaration",
"start_line": 1
}
},
{
"op": "subtypes",
"result": {
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "declaration",
"start_line": 5
}
},
{
"op": "members",
"result": {
"end_line": 6,
"fq_name": "QueryLeaf.leafMember",
"kind": "function",
"path": "typescript/hierarchy.ts",
"result_type": "declaration",
"start_line": 6
}
},
{
"op": "owner",
"result": {
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "typescript/hierarchy.ts",
"result_type": "declaration",
"start_line": 5
}
}
]
}
],
"result_type": "declaration",
"signature": "class QueryLeaf extends QueryRoot {",
"start_line": 5
}
],
"truncated": false
}