Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !5537

Respect tsconfig.json extends when validating config

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/ianschmitz/parse-tsconfig into master Oct 23, 2018
  • Overview 9
  • Commits 3
  • Pipelines 0
  • Changes 3

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: image

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,
        },
    },
}
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ianschmitz/parse-tsconfig