Skip to content

feat: please support the "extends" setting in tsconfig.json (configuration inheritance) #173

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
atamocius opened this issue Sep 5, 2017 · 5 comments
Labels

Comments

@atamocius
Copy link

It would be nice if the extends property of tsconfig.json was supported.

I found out the hard way that it wasn't supported. I was getting an Uppercase/lowercase mismatch error. I found out that it was because my tsconfig.json was using the extends property to inherit from a common config file where the baseUrl was defined.

@erikbarke
Copy link
Collaborator

erikbarke commented Sep 5, 2017

Hey @antonmata, I modified the typescript-latest example project like this:

Karma config:

module.exports = function(config) {
    config.set({

        frameworks: ["jasmine", "karma-typescript"],

        files: [
            { pattern: "src/**/*.ts" }
        ],

        preprocessors: {
            "**/*.ts": ["karma-typescript"]
        },

        karmaTypescriptConfig: {
            tsconfig: "./tsconfig.json"
        },

        reporters: ["dots", "karma-typescript"],

        browsers: ["Chrome"]
    });
};

tsconfig.json:

{
    "extends": "./base-tsconfig.json",
    "compileOnSave": false,
    "exclude": [
        "node_modules"
    ]
}

base-tsconfig.json (this is a new file I created for this test):

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "outDir": "tmp",
        "target": "ES5",
        "sourceMap": true,
        "types" : [
            "jasmine"
        ]
    }
}

Does this describe your scenario? It works when I run npm test, I can change settings in base-tsconfig.json to change the compiler behavior.

Are you on an OS with a case sensitive file system? The "Uppercase/lowercase mismatch" error is thrown by the dependency walker if a module is imported with a different case than its file name, ie import { Service } from "./service"; from the file Service.ts, so you probably have a mismatch somewhere in your code.

@atamocius
Copy link
Author

The key item for me was the baseUrl. To best describe my scenario, you need to add the baseUrl in base-tsconfig.json and also define appropriate resolve.modules in webpack:

resolve: {
    extensions: [".tsx", ".ts", ".js", ".json"],
    modules: [
        __dirname,
        "node_modules"
    ]
}

I kind of figured out that it could be a path issue because I was getting a Error: Uppercase/lowercase mismatch message from an error thrown in dependency-walker.ts.

@atamocius
Copy link
Author

I forgot to mention that I was able to workaround the issue by explicitly defining the baseUrl in the "child" tsconfig.json that was referenced by karma-typescript, essentially bypassing the inheritance.

@erikbarke
Copy link
Collaborator

I was able reproduce the error and this is probably a Typescript bug, microsoft/TypeScript#17617.

The compiler seems to lowercase module names if the baseUrl property is set in a tsconfig that is inherited, just like what you're describing.

This triggers the case sensitivity validators in both karma-typescript and the Typescript compiler, if you're using the forceConsistentCasingInFileNames compiler option.

@atamocius
Copy link
Author

Ah ok, that explains a lot. I was so confused that the error message was showing both paths, but they look alike except for just the casing. I really did not know what or how to fix that, hence just went for the workaround. Thanks for looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants