Skip to content

tsconfig - validate and warn about unknown/unexpected properties #38006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
levenleven opened this issue Apr 16, 2020 · 5 comments
Closed
5 tasks done

tsconfig - validate and warn about unknown/unexpected properties #38006

levenleven opened this issue Apr 16, 2020 · 5 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@levenleven
Copy link

Search Terms

tsconfig validate

Suggestion

Currently tsc validates and warns about invalid properties in compilerOptions section which is great!. It would be really helpful if it would do the same for the root of the config file.

Use Cases

Easily identify mistakes/typos in configuration.

Examples

Sometimes people put complier option in the root by mistake, then scratching the head for hours trying to understand what is wrong.

In example below path mapping obviously won't work:

{
  "compilerOptions": {
    ...
  },
  "paths": {
    "@module": [
      "./src/utils/module"
    ]
  },
  "include": [
    ...
  ]
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Apr 16, 2020
@RyanCavanaugh
Copy link
Member

The top level is intentionally kept "open" so that other tools wanting to interop with TS projects can store configuration data there.

@levenleven
Copy link
Author

Maybe there could be "check for unknown config props" mode or something like that.. Anyway thanks for explanation @RyanCavanaugh

@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@botic
Copy link

botic commented Aug 10, 2021

@RyanCavanaugh Maybe a warning if e.g. outDir is specified in the root of tsconfig instead of compilerOptions? Just took me 20 minutes to find my typo:

{
    "extends": "@tsconfig/node16/tsconfig.json",
    "include": [
        "src/*" ,"src/**/*"
    ],
    "outDir": "dist"
}

For beginners it might not be obvious that include and outDir are not on the same level.

@RyanCavanaugh
Copy link
Member

@botic see #44964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants