Skip to content

Commit

Permalink
fix: generate types when using custom tsconfig path.(#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
uinz committed Oct 23, 2024
1 parent 9f1195f commit 2afcce4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utils/get-rollup-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const getConfig = {
module: ts.default.ModuleKind.Preserve,
moduleResolution: ts.default.ModuleResolutionKind.Bundler,
},
tsconfig: tsconfig?.path

Check failure on line 83 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Missing trailing comma
}) as Plugin,
],
output: [] as unknown as Output,
Expand Down
29 changes: 29 additions & 0 deletions tests/specs/builds/output-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,34 @@ export default testSuite(({ describe }, nodePath: string) => {
expect(types).toMatch('\'dep-a\'');
expect(types).toMatch('.data');
});

test('custom tsconfig.json path', async () => {
await using fixture = await createFixture({
...packageFixture({ installTypeScript:true, installReact: true }),

Check failure on line 456 in tests/specs/builds/output-types.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Missing space before value for key 'installTypeScript'

Check failure on line 456 in tests/specs/builds/output-types.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Object properties must go on a new line
'package.json': createPackageJson({
types: './dist/component.d.ts',
peerDependencies: {
react: '*',
},
}),
'tsconfig.custom.json': createTsconfigJson({
compilerOptions: {
jsx: 'react-jsx',
},
}),
});

const pkgrollProcess = await pkgroll(['-p', 'tsconfig.custom.json'], {
cwd: fixture.path,
nodePath,
});

expect(pkgrollProcess.exitCode).toBe(0);
expect(pkgrollProcess.stderr).toBe('');

const content = await fixture.readFile('dist/component.d.ts', 'utf8');
expect(content).toMatch(`declare const Component: () => react_jsx_runtime.JSX.Element`);

Check failure on line 479 in tests/specs/builds/output-types.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Strings must use singlequote
expect(content).toMatch('export { Component }');
});
});
});

0 comments on commit 2afcce4

Please sign in to comment.