New config option onlySafeImports
Proposed Changes
- Add option
reflection.onlySafeImports: boolean, - in case the onlySafeImports is true, all Type descriptions of types from
node_moduleswill have plainObjectas ctor.
Notes
Type.getTypes().forEach(type => type.ctor) is dangerous action, because if some Type is from node_modules and it looks like:
export class Foo {}
deleteAllTheFilesOnYourPc()
it can do some damage.
New include/exclude config options can exclude all the node_modules types, so there is an option to ignore them all.
But somebody would want to work with those types, but stay safe and tell: "No, don't import those modules in case I acidentaly do that."
Another thing we can do is check if there is some CallExpression in SourceFile statements.. for modules inside node_modules.
But this will be still dangerous:
Type.getTypes().forEach(type => (new type.ctor())[type.getMethods()[0]])
I do the mistake that I'm calling unknown methods but still... onlySafeImports should care about that and ignoring whole import of node_modules in safe mode is much safer.
Can be controlled by the include/exclude manually.
onlySafeImports needs more feedback.