module

Noir::TsClassFields

The property names a TypeScript class, interface or object type declares, and the types it inherits them from. Built for request DTOs (@Body() body: CreateUserDto): no file I/O, the caller resolves base names to declarations.

Constants

CONTINUES = {':', '=', '|', '&', ',', '<', '(', '[', '?'}

A line ending in one of these continues onto the next: kind:\n Foo;.

DECL_HEAD = /\b(?:class|interface)\s+([A-Za-z_$][\w$]*)\s*(?:<(?:[^<>{}]|<[^<>{}]*>)*>)?([^{;]*)\{/
FUNCTION_VALUE = /\A\s*(?:async\s*)?(?:\(\s*\)|[A-Za-z_$][\w$]*)\s*(?::[^=;\n]*)?=>/

A member whose value is a function (handler = () => ..., cb: (x) => void) is behaviour, not request data.

MAPPED = /\A(PartialType|PickType|OmitType|IntersectionType|RequiredType)\s*\(/
MEMBER = /(?:\A|[;,}\n])\s*(?:@[\w$.]+\s*(?:\(\s*\))?\s*)*(?:(?:public|readonly|declare|override)\s+)*([A-Za-z_$][\w$]*)\s*[?!]?\s*[:=;,\n]/

A member head at the top level of a body whose nested (...), [...] and {...} were blanked: decorators, modifiers, then name?:, name!:, name = or name;. A method (name(), accessor (get name(), static or non-public member does not match.

ZOD_DTO = /\AcreateZodDto\s*\(/

nestjs-zod's class X extends createZodDto(Schema) {}.

ZOD_OBJECT_DECL = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=\n]+)?=\s*z\s*\.\s*(?:object|strictObject|looseObject)\s*\(\s*\{/

Class methods

declarations(code : String) : Hash(String, Decl)

Every class/interface declared in code (comments already stripped), by name; the first declaration of a name wins.

Source
heritage(header : String) : Array(Base)

extends Base<T>, extends PickType(Base, ['a'] as const), extends IntersectionType(A, PartialType(B)); interfaces may extend several (extends A, B). implements names no fields.

Source
members(body : String) : Array(String)
Source
object_type_fields(type : String) : Array(String)

Property names of an inline object type { a: string; b?: number }.

Source
type_bases(expr : String) : Array(Base)
Source

Nested types