-
Notifications
You must be signed in to change notification settings - Fork 460
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
Comments in tsconfig.json #139
Comments
@jonaskello thank you for reporting this and proposing a solution. The fix is in and has been published. |
@kulshekhar Thanks for the quick fix, now I can add my comments back in :-). |
I tested some more and found one case where it does not work. If you have extends in |
@jonaskello thanks again! The fix is in and published |
This is still broken, when I have a comment in the import type { Config } from 'jest';
import { pathsToModuleNameMapper } from 'ts-jest';
import { compilerOptions } from './tsconfig.json';
const config: Config = {
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/', useESM: true }),
},
};
export default config; |
@b3nk3 It works when replacing the import of the json-configuration by a custom solution described in https://stackoverflow.com/a/53898219/517914. According to the author, this should also work when extending the ts-config file. /** @type {import('ts-jest').JestConfigWithTsJest} */
import type { Config } from 'jest';
import { pathsToModuleNameMapper } from 'ts-jest';
import ts from 'typescript';
const configFileName = ts.findConfigFile('./', ts.sys.fileExists, 'tsconfig.json');
const configFile = ts.readConfigFile(configFileName!, ts.sys.readFile);
const compilerOptions = ts.parseJsonConfigFileContent(configFile.config, ts.sys, './');
const config: Config = {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.options.paths!, {
prefix: '<rootDir>',
}),
};
export default config; |
Typescript allows comments in tsconfig.json. When I started using ts-jest it did not like my comments. I know JSON itself does not allow comments but it would be nice if ts-jest could follow typescript on this.
Specifically I got this error:
Comments OK in tsconfig.json.
I think one way to solve it would be to use the tsconfig package that replicates how typescript parses tsconfig.
The text was updated successfully, but these errors were encountered: