Skip to content

noImplicitAny from parent tsconfig.json cannot be overriddenΒ #55983

@digeomel

Description

@digeomel

πŸ”Ž Search Terms

noImplicitAny

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions because I never needed to set noImplicitAny to true before. The TypeScript version used in my example is 5.1.3.

⏯ Playground Link

No response

πŸ’» Code

https://github.com/digeomel/angular-no-implicit-any

πŸ™ Actual behavior

I have an Angular 15 workspace with a main app and multiple independent projects (aka libraries). For the main app and some projects, I want to set noImplicitAny: true for the TypeScript compiler, but for some others, I want it to remain false (the default). The tsconfig.lib.json files inside the libraries are extending the main tsconfig.json from the root Angular folder (although I tried removing the extends as well, no difference, read below).

The problem is, no matter what I do, I keep getting errors about noImplicitAny from the libraries where it is even explicitly set to false! It seems that the TypeScript compiler disregards the individual tsconfig.lib.json settings inside those libraries and takes the global setting.

Moreover, I tried moving the setting from the main tsconfig.json in the root folder, to the app-specific src/tsconfig.app.json and I still get the same error from the libraries!

These are the other contents of the main tsconfig.json file:

{
    "compilerOptions": {
        "baseUrl": "./",
        "outDir": "./dist/out-tsc",
        "module": "es2022",
        "target": "es2022",
        "lib": ["es2022", "dom"],
        "forceConsistentCasingInFileNames": true,
        "noImplicitOverride": true,
        "noPropertyAccessFromIndexSignature": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "sourceMap": true,
        "declaration": false,
        "downlevelIteration": true,
        "moduleResolution": "node",
        "emitDecoratorMetadata": false,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "importHelpers": true,
        "typeRoots": ["node_modules/@types"],
        "resolveJsonModule": true,
    },
    "angularCompilerOptions": {
        "enableI18nLegacyMessageIdFormat": false,
        "strictInjectionParameters": true,
        "strictInputAccessModifiers": true,
        "strictTemplates": true
    }
}

We are not using "full" TypeScript strict mode.

What am I missing?

πŸ™‚ Expected behavior

I expect that the TypeScript compiler will respect the individual project settings and overrides. In my example above, the test2 library has this tsconfig.lib.json:

{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
        "outDir": "../../out-tsc/lib",
        "declaration": true,
        "declarationMap": true,
        "inlineSources": true,
        "noImplicitAny": false,
        "types": []
    },
    "exclude": ["**/*.spec.ts"]
}

So, noImplicitAny is set to false, however I'm getting an error in test2.component.ts:

image

Additional information about the issue

Not sure if this is about the Angular compiler or the TypeScript compiler, if you think it's Angular, please close the issue and I will post it in the Angular repo issues.

I also posted this on stackoverflow, with no luck, that's why I'm trying here as well:
https://stackoverflow.com/questions/77214574/angular-tsconfig-cannot-use-different-noimplicitany-settings-for-different-proje

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions