Big refactoring of the TypeScript importer.