Implemented the TypeScript def for 'plugins/serializer'

-Also fixed some comments and syntax issues in the module code.
-Cleaned up some TS def scoping.