Protected
addProtected
addProtected
compileTypes added to this map will get a type program directly under it. This is for types used in the very same file.
Protected
compiledWhen a node was embedded or compiled (from the maps above), we store it here to know to not add it again.
Protected
contextProtected
currentProtected
embedProtected
embedTypes added to this map will get a type program at the top root level of the program. This is for imported types, which need to be inlined into the current file, as we do not emit type imports (TS will omit them).
Protected
fProtected
Optional
globalProtected
hostProtected
knownProtected
nodeProtected
Optional
reflectionProtected
Optional
reflectionProtected
resolvedProtected
resolvedProtected
resolverProtected
Optional
tempWhen an deep call expression was found a script-wide variable is necessary as temporary storage.
Protected
Optional
typeProtected
applyProtected
createProtected
createProtected
decorateProtected
decorateA class is decorated with type information by adding a static variable.
class Model { static __types = pack(ReflectionOp.string); //<-- encoded type information title: string; }
Protected
decoratefunction name() {}
=> function name() {}; name.__type = 34;
Protected
decorateProtected
extractProtected
extractProtected
findProtected
findProtected
findProtected
followProtected
getProtected
getProtected
getProtected
getProtected
injectProtected
isProtected
needsWith this function we want to check if type
is used in the signature itself from the parent of declaration
.
If so, we do not try to infer the type from runtime values.
Examples where we do not infer from runtime, type
being T
and declaration
being <T>
(return false):
class User<T> {
config: T;
}
class User<T> {
constructor(public config: T) {}
}
function do<T>(item: T): void {}
function do<T>(item: T): T {}
Examples where we infer from runtime (return true):
function do<T>(item: T) {
return typeOf<T>; //<-- because of that
}
function do<T>(item: T) {
class A {
config: T; //<-- because of that
}
return A;
}
function do<T>(item: T) {
class A {
doIt() {
class B {
config: T; //<-- because of that
}
return B;
}
}
return A;
}
function do<T>(item: T) {
class A {
doIt(): T { //<-- because of that
}
}
return A;
}
Protected
packProtected
parseProtected
readProtected
resolveThis is a custom resolver based on populated locals
from the binder. It uses a custom resolution algorithm since
we have no access to the binder/TypeChecker directly and instantiating a TypeChecker per file/transformer is incredible slow.
Protected
resolveProtected
resolveProtected
valueNote: We have to duplicate the expressions as it can be that incoming expression are from another file and contain wrong pos/end properties,
so the code generation is then broken when we simply reuse them. Wrong code like User.__type = [.toEqual({
is then generated.
This function is probably not complete, but we add new copies when required.
Optional
options: ReflectionOptionsProtected
wrapGenerated using TypeDoc
Read the TypeScript AST and generate pack struct (instructions + pre-defined stack).
This transformer extracts type and add the encoded (so its small and low overhead) at classes and functions as property.
Deepkit/type can then extract and decode them on-demand.