Skip to content

Commit 60d2a79

Browse files
authored
fix(typescript): Use builtin extends resolution (#199)
1 parent c1df35b commit 60d2a79

File tree

7 files changed

+35
-6
lines changed

7 files changed

+35
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pnpm-debug.log
1212

1313
!packages/node-resolve/test/fixtures/**/node_modules
1414
!packages/commonjs/test/**/node_modules
15+
!packages/typescript/test/fixtures/**/node_modules

packages/typescript/src/options.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ function readTsConfigFile(ts: typeof import('typescript'), tsConfigPath: string)
114114
throw Object.assign(Error(), diagnosticToWarning(ts, null, error));
115115
}
116116

117-
const extendedTsConfig: string = config?.extends;
118-
if (extendedTsConfig) {
119-
// Get absolute path of `extends`, starting at basedir of the tsconfig file.
120-
config.extends = resolve(process.cwd(), tsConfigPath, '..', extendedTsConfig);
121-
}
122-
123117
return config || {};
124118
}
125119

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const props = {};
2+
// @ts-ignore
3+
export default <span {...props}>Yo!</span>;

packages/typescript/test/fixtures/tsconfig-extends-module/node_modules/shared-config/package.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/typescript/test/fixtures/tsconfig-extends-module/node_modules/shared-config/tsconfig.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "shared-config",
3+
"compilerOptions": {
4+
"allowJs": true
5+
}
6+
}

packages/typescript/test/test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,22 @@ test.serial('should support extends property with given tsconfig', async (t) =>
347347
t.not(usage, -1, 'should contain usage');
348348
});
349349

350+
test.serial('should support extends property with node resolution', async (t) => {
351+
process.chdir('fixtures/tsconfig-extends-module');
352+
353+
const bundle = await rollup({
354+
input: 'main.tsx',
355+
plugins: [
356+
typescript()
357+
],
358+
onwarn
359+
});
360+
const code = await getCode(bundle, outputOptions);
361+
362+
const usage = code.includes('React.createElement("span", __assign({}, props), "Yo!")');
363+
t.true(usage, 'should contain usage');
364+
});
365+
350366
test('complies code that uses browser functions', async (t) => {
351367
const bundle = await rollup({
352368
input: 'fixtures/dom/main.ts',

0 commit comments

Comments
 (0)