Skip to content

Commit

Permalink
fix(typescript): Use builtin extends resolution (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods authored Feb 6, 2020
1 parent c1df35b commit 60d2a79
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pnpm-debug.log

!packages/node-resolve/test/fixtures/**/node_modules
!packages/commonjs/test/**/node_modules
!packages/typescript/test/fixtures/**/node_modules
6 changes: 0 additions & 6 deletions packages/typescript/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ function readTsConfigFile(ts: typeof import('typescript'), tsConfigPath: string)
throw Object.assign(Error(), diagnosticToWarning(ts, null, error));
}

const extendedTsConfig: string = config?.extends;
if (extendedTsConfig) {
// Get absolute path of `extends`, starting at basedir of the tsconfig file.
config.extends = resolve(process.cwd(), tsConfigPath, '..', extendedTsConfig);
}

return config || {};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const props = {};
// @ts-ignore
export default <span {...props}>Yo!</span>;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "shared-config",
"compilerOptions": {
"allowJs": true
}
}
16 changes: 16 additions & 0 deletions packages/typescript/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,22 @@ test.serial('should support extends property with given tsconfig', async (t) =>
t.not(usage, -1, 'should contain usage');
});

test.serial('should support extends property with node resolution', async (t) => {
process.chdir('fixtures/tsconfig-extends-module');

const bundle = await rollup({
input: 'main.tsx',
plugins: [
typescript()
],
onwarn
});
const code = await getCode(bundle, outputOptions);

const usage = code.includes('React.createElement("span", __assign({}, props), "Yo!")');
t.true(usage, 'should contain usage');
});

test('complies code that uses browser functions', async (t) => {
const bundle = await rollup({
input: 'fixtures/dom/main.ts',
Expand Down

0 comments on commit 60d2a79

Please sign in to comment.