Skip to content
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

Disable composite for type declarations #54

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions src/utils/get-rollup-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
async type(
options: Options,
) {
const dts = await import('rollup-plugin-dts');

Check warning on line 42 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Maximum number of dependencies (15) exceeded

return {
input: [] as string[],
Expand All @@ -49,6 +49,7 @@
resolveTypescriptMjsCts(),
dts.default({
respectExternal: true,
compilerOptions: { composite: false },
}) as Plugin,
],
output: [] as unknown as Output,
Expand Down Expand Up @@ -117,7 +118,7 @@
[T in keyof GetConfig]?: Awaited<ReturnType<GetConfig[T]>>;
};

export async function getRollupConfigs(

Check warning on line 121 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Async function 'getRollupConfigs' has too many parameters (6). Maximum allowed is 5
sourceDirectoryPath: string,
distributionDirectoryPath: string,
inputs: {
Expand Down
1 change: 1 addition & 0 deletions tests/fixture-monorepo/packages/one/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Name } from './name.js';
3 changes: 3 additions & 0 deletions tests/fixture-monorepo/packages/one/src/name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare const name: unique symbol;

export type Name = string & { [name]: never };
9 changes: 9 additions & 0 deletions tests/fixture-monorepo/packages/one/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"jsx": "react",
"moduleResolution": "node",
"composite": true,
"outDir": "dist"
},
"include": ["src/index.ts"]
halostatue marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 5 additions & 0 deletions tests/fixture-monorepo/packages/two/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Name } from '@org/one';

Check failure on line 1 in tests/fixture-monorepo/packages/two/src/index.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unable to resolve path to module '@org/one'

export function sayHello(name: Name) {
console.log('Hello', name);

Check warning on line 4 in tests/fixture-monorepo/packages/two/src/index.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected console statement
}
10 changes: 10 additions & 0 deletions tests/fixture-monorepo/packages/two/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"jsx": "react",
"moduleResolution": "node",
"composite": true,
"outDir": "dist"
},
"include": ["src/index.ts"],
"references": [{ "path": "../one" }]
}
6 changes: 6 additions & 0 deletions tests/fixture-monorepo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"moduleResolution": "node"
},
"resources": [{ "path": "./packages/one" }, { "path": "./packages/two" }]
}
39 changes: 39 additions & 0 deletions tests/specs/builds/output-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,44 @@ export default testSuite(({ describe }, nodePath: string) => {
const content = await fixture.readFile('dist/dts.d.ts', 'utf8');
expect(content).toMatch('declare const');
});

test('handles types in composite monorepos correctly', async ({ onTestFinish }) => {
const fixture = await createFixture('./tests/fixture-monorepo');
onTestFinish(async () => await fixture.rm());

await installTypeScript(fixture.path);

await fixture.writeJson('package.json', {
workspaces: ['packages/*'],
});

await fixture.writeJson('packages/one/package.json', {
name: '@org/one',
type: 'module',
exports: { types: './dist/index.d.mts' },
});

const pkgrollOne = await pkgroll([], { cwd: `${fixture.path}/packages/one`, nodePath });
expect(pkgrollOne.exitCode).toBe(0);
expect(pkgrollOne.stderr).toBe('');

const contentOne = await fixture.readFile('packages/one/dist/index.d.mts', 'utf8');
expect(contentOne).toMatch('export type { Name };');

await fixture.writeJson('packages/two/package.json', {
main: './dist/index.mjs',
type: 'module',
dependencies: {
'@org/one': 'workspace:*',
},
});

const pkgrollTwo = await pkgroll([], { cwd: `${fixture.path}/packages/two`, nodePath });
expect(pkgrollTwo.exitCode).toBe(0);
expect(pkgrollTwo.stderr).toBe('');

const contentTwo = await fixture.readFile('packages/two/dist/index.mjs', 'utf8');
expect(contentTwo).toMatch('export { sayHello };');
});
});
});
Loading