TypeScript typings cause very high memory usage in tsc
Author: yjwongCreated May 27, 2020Updated Feb 27, 2026
Labelstype: feature request
When importing googleapis within a TypeScript project, tsc takes up a large amount of memory (500 MB+). This appears to be the case because when googleapis is imported, it imports the type definition files for every single API that Google has, even if only a single API (e.g. drive_v3) is required.
Environment details
- OS: Ubuntu 20.04 LTS
- Node.js version: 10.20.1 (LTS)
- npm version: N/A (We don't use npm instally, but we use yarn v1.22.4)
googleapisversion: 51.0.0typescriptversion: 3.8.3
Steps to reproduce
Please see reproduction repository here: https://github.com/yjwong/tsc-googleapis-memory-usage
Essentially, even just a simple:
import { google } from 'googleapis';Will result in high memory usage from tsc.
There is also a related StackOverflow question: https://stackoverflow.com/questions/56599477/typescript-googleapis-surge-in-memory-used
Workaround
Import the APIs individually, like so (example is Google Drive SDK v3):
import { drive_v3 } from 'googleapis/build/src/apis/drive/v3';
import { AuthPlus } from 'googleapis-common/build/src/authplus';Source: googleapis/google-api-nodejs-client