Created by: ianschmitz
This PR enhances #5532 by adding support for extends
in tsconfig.json
. We use the TypeScript compiler to parse the configuration, which traverses the relationships.
Some interesting tidbits:
The output from ts.readConfigFile()
is mutated after running ts.parseJsonConfigFileContent()
which merges in include
and exclude
from extended config files, but leaves the compilerOptions
untouched:
We then use ts.parseJsonConfigFileContent()
which gives us a parsed options
among other things. For example you can see how module
is missing from raw
, but is present in options
, as it was included by extending tsconfig.test.json
:
{
options: {
pretty: true,
target: 1,
allowJs: true,
skipLibCheck: true,
esModuleInterop: true,
allowSyntheticDefaultImports: true,
strict: true,
module: 6,
moduleResolution: 2,
resolveJsonModule: true,
isolatedModules: true,
noEmit: true,
jsx: 1,
configFilePath: undefined,
},
fileNames: [
"C:/Projects/create-react-app/packages/react-scripts/template/src/App.js",
"C:/Projects/create-react-app/packages/react-scripts/template/src/index.tsx",
"C:/Projects/create-react-app/packages/react-scripts/template/src/react-app.d.ts",
"C:/Projects/create-react-app/packages/react-scripts/template/src/serviceWorker.d.ts",
"C:/Projects/create-react-app/packages/react-scripts/template/src/serviceWorker.js",
],
projectReferences: undefined,
typeAcquisition: { enable: false, include: [], exclude: [] },
raw: {
extends: "./tsconfig.test.json",
compileOnSave: false,
compilerOptions: {
target: "es5",
allowJs: true,
skipLibCheck: true,
esModuleInterop: true,
allowSyntheticDefaultImports: true,
strict: true,
moduleResolution: "node",
resolveJsonModule: true,
isolatedModules: true,
noEmit: true,
jsx: "preserve",
},
},
errors: [],
wildcardDirectories: {
"C:/Projects/create-react-app/packages/react-scripts/template/src": 1,
},
compileOnSave: false,
configFileSpecs: {
filesSpecs: undefined,
includeSpecs: ["src"],
excludeSpecs: ["**/__tests__/**", "**/?*test.*", "**/?*spec.*"],
validatedIncludeSpecs: ["src"],
validatedExcludeSpecs: [
"**/__tests__/**",
"**/?*test.*",
"**/?*spec.*",
],
wildcardDirectories: {
"C:/Projects/create-react-app/packages/react-scripts/template/src": 1,
},
},
}