module

Noir::TsDecoratorExtractor

Decorated classes of a TypeScript / JavaScript source, read off the TypeScript AST: the class's decorators, and per decorated method its decorators and decorated parameters. Shared by the decorator-controller analyzers (NestJS, Midway, tsoa, routing-controllers, Ts.ED, inversify, n8n) and the NestJS auth tagger, so a decorator split over lines, an argument holding ) in a string, or @Get( inside a string or comment read the same everywhere.

Decorator arguments are kept as source text: the callers decode them with their own literal tables ('users', RouteKey.User, { path, version }).

Constants

CLASS_TYPES = {"class_declaration", "abstract_class_declaration", "class"}

Class methods

extract(source : String, path : String) : Array(ClassDecl)

Every decorated class in source, outer classes first. JavaScript goes through the TSX grammar: the JavaScript grammar has no parameter decorators, which Babel-compiled Nest code uses, and JSX in a .js handler needs TSX, a safe superset where no <T>x cast can appear.

Source

Nested types