Skip to content

Commit

Permalink
Merge pull request #3703 from terascope/rework-sync-tsconfig
Browse files Browse the repository at this point in the history
rework generateTSConfig
  • Loading branch information
jsnoble committed Jul 25, 2024
2 parents ef270af + ad80fbe commit 40a66dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 54 deletions.
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/scripts",
"displayName": "Scripts",
"version": "0.82.0",
"version": "0.83.0",
"description": "A collection of terascope monorepo scripts",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/scripts#readme",
"bugs": {
Expand Down
6 changes: 6 additions & 0 deletions packages/scripts/src/helpers/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ export function getRootInfo(): RootPackageInfo {
return _rootInfo;
}

export function getRootTsConfig(): Record<string, any> {
const rootTsConfig = path.join(getRootDir(), 'tsconfig.json');
if (!fse.existsSync(rootTsConfig)) return { };
return fse.readJSONSync(rootTsConfig);
}

export function getAvailableTestSuites(): string[] {
return Object.keys(getRootInfo().terascope.tests.suites);
}
Expand Down
55 changes: 2 additions & 53 deletions packages/scripts/src/helpers/sync/configs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { isString } from '@terascope/utils';
import { getRootInfo, writeIfChanged } from '../misc';
import { getRootInfo, getRootTsConfig, writeIfChanged } from '../misc';
import { PackageInfo } from '../interfaces';

export async function generateTSConfig(
Expand All @@ -19,57 +18,7 @@ export async function generateTSConfig(
}));

const tsconfig = {
compilerOptions: {
baseUrl: '.',
module: 'commonjs',
moduleResolution: 'node',
target: rootInfo.terascope.target,
skipLibCheck: true,
experimentalDecorators: true,
strict: true,
// FIXME we should enable this someday
useUnknownInCatchVariables: false,
noFallthroughCasesInSwitch: true,
preserveConstEnums: true,
esModuleInterop: true,
resolveJsonModule: true,
forceConsistentCasingInFileNames: true,
suppressImplicitAnyIndexErrors: true,
ignoreDeprecations: '5.0',

// Require project settings
composite: true,
declaration: true,
declarationMap: true,
sourceMap: true,
isolatedModules: true,
// https://www.typescriptlang.org/tsconfig#disableReferencedProjectLoad
disableReferencedProjectLoad: true,
...(rootInfo.terascope.version !== 2 ? {
typeRoots: [
fs.existsSync(path.join(rootInfo.dir, './types'))
? './types'
: undefined,
fs.existsSync('./node_modules/@types')
? './node_modules/@types'
: undefined
].filter(isString),
paths: {
'*': ['*', './types/*']
}
} : {}),
...rootInfo.terascope.compilerOptions
},
include: [],
exclude: [
fs.existsSync('./node_modules')
? '**/node_modules'
: undefined,
'**/.*/',
rootInfo.terascope.version === 2 ? '.yarn/releases/*' : undefined,
'**/build/**/*'
].filter(isString),
// these project references should be ordered by dependents first
...getRootTsConfig(),
references
};

Expand Down

0 comments on commit 40a66dd

Please sign in to comment.