| 
1 | 1 | /* eslint-disable no-console */  | 
2 | 2 | const { execSync } = require('child_process');  | 
3 | 3 | const { join } = require('path');  | 
4 |  | -const { writeFileSync } = require('fs');  | 
 | 4 | +const { readFileSync, writeFileSync } = require('fs');  | 
5 | 5 | 
 
  | 
6 | 6 | const cwd = join(__dirname, '../../..');  | 
7 | 7 | 
 
  | 
 | 8 | +// Newer versions of the Express types use syntax that isn't supported by TypeScript 3.8.  | 
 | 9 | +// We'll pin to the last version of those types that are compatible.  | 
 | 10 | +console.log('Pinning Express types to old versions...');  | 
 | 11 | + | 
 | 12 | +const packageJsonPath = join(cwd, 'package.json');  | 
 | 13 | +const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));  | 
 | 14 | + | 
 | 15 | +if (!packageJson.resolutions) packageJson.resolutions = {};  | 
 | 16 | +packageJson.resolutions['@types/express'] = '4.17.13';  | 
 | 17 | +packageJson.resolutions['@types/express-serve-static-core'] = '4.17.30';  | 
 | 18 | + | 
 | 19 | +writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));  | 
 | 20 | + | 
8 | 21 | const tsVersion = '3.8';  | 
9 | 22 | 
 
  | 
10 | 23 | console.log(`Installing typescript@${tsVersion}, and @types/node@14...`);  | 
11 | 24 | 
 
  | 
12 |  | -execSync(`yarn add --dev --ignore-workspace-root-check typescript@${tsVersion} @types/node@^14`, {  | 
13 |  | -  stdio: 'inherit',  | 
14 |  | -  cwd,  | 
15 |  | -});  | 
 | 25 | +execSync(  | 
 | 26 | +  `yarn add --dev --ignore-workspace-root-check typescript@${tsVersion} @types/node@^14 @types/[email protected] @types/[email protected]`,  | 
 | 27 | +  {  | 
 | 28 | +    stdio: 'inherit',  | 
 | 29 | +    cwd,  | 
 | 30 | +  },  | 
 | 31 | +);  | 
16 | 32 | 
 
  | 
17 | 33 | console.log('Removing unsupported tsconfig options...');  | 
18 | 34 | 
 
  | 
19 | 35 | const baseTscConfigPath = join(cwd, 'packages/typescript/tsconfig.json');  | 
20 | 36 | 
 
  | 
21 | 37 | const tsConfig = require(baseTscConfigPath);  | 
22 | 38 | 
 
  | 
23 |  | -// TS 3.8 fails build when it encounteres a config option it does not understand, so we remove it :(  | 
 | 39 | +// TS 3.8 fails build when it encounters a config option it does not understand, so we remove it :(  | 
24 | 40 | delete tsConfig.compilerOptions.noUncheckedIndexedAccess;  | 
25 | 41 | 
 
  | 
26 | 42 | writeFileSync(baseTscConfigPath, JSON.stringify(tsConfig, null, 2));  | 
0 commit comments