import * as ts from "typescript" ; import * as Types from "../runtime/publicTypes" ; import { TypeKind } from "../runtime/publicTypes" ; export { TypeKind } ; export type ScopeType = ts . SourceFile | ts . CaseBlock | ts . ModuleBlock | ts . Block ; export class Ctx { constructor ( readonly checker , readonly node , readonly currentScope , readonly markReferenced ) { } reportUnknownType = ( type ) => { const { checker } = this ; const msg = `unknown type, ${ checker . typeToString ( type ) }` ; this . reportWarning ( msg ) ; } ; reportWarning = ( msg ) => { const { node } = this ; const fname = node . getSourceFile ( ) . fileName ; const location = node . getSourceFile ( ) . getLineAndCharacterOfPosition ( node . getStart ( ) ) ; const node_text = node . getText ( ) ; console . warn ( `\n\ntsruntime: ${ msg }: ${ fname } ${ location . line }:${ location . character }: ${ node_text }\n` ) ; } ; } export type ReflectedType = ClassType | ObjectType | TupleType | ReferenceType | UnionType | Override2 < Types . FunctionType > | Override2 < Types . StringLiteralType > | Override2 < Types . NumberLiteralType > | Override2 < Types . SimpleTypes > ; type _Override < T , O > = Pick < T , Exclude < keyof T , keyof O > > & O ; type Override < T , O > = _Override < T , O & { initializer ? : ts . Expression ; } > ; type Override2 < T > = Override < T , { } > ; type Properties = Array < { name : ts . PropertyName ; type : ReflectedType ; } > ; export type ObjectType = Override < Types . ObjectType , { properties : Properties ; } > ; export type TupleType = Override < Types . TupleType , { elementTypes : ReflectedType [ ] ; } > ; export type UnionType = Override < Types . UnionType , { types : ReflectedType [ ] ; } > ; export type ReferenceType = Override < Types . ReferenceType , { arguments : ReflectedType [ ] ; } > ; export interface ConstructorParameter { name : string ; modifiers : ts . ModifierFlags ; type : ReflectedType ; } export interface Constructor { modifiers : ts . ModifierFlags ; parameters : ConstructorParameter [ ] ; } export type Constructors = Array < Constructor > ; export type ClassType = Override < Types . ClassType , { properties : Properties ; constructors : Constructors ; extends ? : ReflectedType ; } > ;