Skip to content

fix: default moduleResolution for module: preserve #90

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/parse-tsconfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'exclude',
] as const;

const resolveExtends = (

Check warning on line 17 in src/parse-tsconfig/index.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Arrow function has a complexity of 12. Maximum allowed is 10
extendsPath: string,
fromDirectoryPath: string,
circularExtendsTracker: Set<string>,
Expand Down Expand Up @@ -91,7 +91,7 @@
'declarationDir',
] as const;

const _parseTsconfig = (

Check warning on line 94 in src/parse-tsconfig/index.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Arrow function has a complexity of 26. Maximum allowed is 10
tsconfigPath: string,
cache?: Cache<string>,
circularExtendsTracker = new Set<string>(),
Expand Down Expand Up @@ -291,7 +291,6 @@

if (target === 'esnext') {
compilerOptions.module ??= 'es6';
Copy link
Contributor Author

@sxzz sxzz May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've set the default value for module here, and the default value for moduleResolution will be set after line 321.
https://github.com/sxzz/get-tsconfig/blob/ef1aad00c28d4ba6b8494204f468b510567e433c/src/parse-tsconfig/index.ts#L363-L376

compilerOptions.moduleResolution ??= 'classic';
compilerOptions.useDefineForClassFields ??= true;
}

Expand All @@ -308,7 +307,6 @@
|| target === 'es2024'
) {
compilerOptions.module ??= 'es6';
compilerOptions.moduleResolution ??= 'classic';
}

if (
Expand Down
18 changes: 18 additions & 0 deletions tests/specs/parse-tsconfig/parses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ export default testSuite(({ describe }) => {
expect(expectedTsconfig).toStrictEqual(parsedTsconfig);
});

test('implicit config', async () => {
await using fixture = await createFixture({
'file.ts': '',
'tsconfig.json': createTsconfigJson({
compilerOptions: {
target: 'es2022',
module: 'preserve',
},
}),
});

const parsedTsconfig = parseTsconfig(fixture.getPath('tsconfig.json'));
const expectedTsconfig = await getTscTsconfig(fixture.path);
delete expectedTsconfig.files;

expect(expectedTsconfig).toStrictEqual(parsedTsconfig);
});

describe('baseUrl', ({ test }) => {
test('relative path', async () => {
await using fixture = await createFixture({
Expand Down
Loading