Skip to content

Commit 80b7c37

Browse files
committed
Add compiler case for workaround solution
1 parent 24985b7 commit 80b7c37

File tree

4 files changed

+223
-0
lines changed

4 files changed

+223
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//// [tests/cases/compiler/declarationEmitPnpmWorkspaceSkipLibCheck.ts] ////
2+
3+
//// [package.json]
4+
{
5+
"name": "@base-lib/react",
6+
"version": "1.0.0",
7+
"exports": {
8+
".": "./index.d.ts"
9+
}
10+
}
11+
12+
//// [index.d.ts]
13+
export { Tooltip } from "./esm/Tooltip";
14+
15+
//// [Tooltip.d.ts]
16+
import { InternalUtil } from "./utils/internal";
17+
export interface TooltipProps { content: string; }
18+
export declare const Tooltip: TooltipProps & { __internal: InternalUtil };
19+
20+
//// [internal.d.ts]
21+
// Internal utility type - should not be referenceable due to exports field
22+
export interface InternalUtil { __private: never; }
23+
24+
//// [package.json]
25+
{
26+
"name": "@base-lib/react",
27+
"version": "1.0.0"
28+
}
29+
30+
//// [index.d.ts]
31+
export * from "../../.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts";
32+
33+
//// [component.ts]
34+
import { Tooltip } from "@base-lib/react";
35+
36+
// This function returns a value whose inferred type includes Tooltip with its internal types.
37+
// Without syntacticNodeBuilder, tsgo will:
38+
// 1. Analyze the function body to infer the return type
39+
// 2. Encounter Tooltip type which has __internal: InternalUtil
40+
// 3. Try to serialize InternalUtil type
41+
// 4. Fail to generate clean specifier (blocked by exports)
42+
// 5. Fall back to relative path through .pnpm directory
43+
// 6. With skipLibCheck, should suppress error instead of reporting TS2742
44+
export function createComponent() {
45+
return {
46+
data: Tooltip
47+
};
48+
}
49+
50+
51+
52+
53+
54+
//// [component.d.ts]
55+
export declare function createComponent(): {
56+
data: {
57+
__internal;
58+
};
59+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//// [tests/cases/compiler/declarationEmitPnpmWorkspaceSkipLibCheck.ts] ////
2+
3+
=== /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts ===
4+
export { Tooltip } from "./esm/Tooltip";
5+
>Tooltip : Symbol(Tooltip, Decl(index.d.ts, 0, 8))
6+
7+
=== /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip.d.ts ===
8+
import { InternalUtil } from "./utils/internal";
9+
>InternalUtil : Symbol(InternalUtil, Decl(Tooltip.d.ts, 0, 8))
10+
11+
export interface TooltipProps { content: string; }
12+
>TooltipProps : Symbol(TooltipProps, Decl(Tooltip.d.ts, 0, 48))
13+
>content : Symbol(TooltipProps.content, Decl(Tooltip.d.ts, 1, 31))
14+
15+
export declare const Tooltip: TooltipProps & { __internal: InternalUtil };
16+
>Tooltip : Symbol(Tooltip, Decl(Tooltip.d.ts, 2, 20))
17+
>TooltipProps : Symbol(TooltipProps, Decl(Tooltip.d.ts, 0, 48))
18+
>__internal : Symbol(__internal, Decl(Tooltip.d.ts, 2, 46))
19+
>InternalUtil : Symbol(InternalUtil, Decl(Tooltip.d.ts, 0, 8))
20+
21+
=== /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal.d.ts ===
22+
// Internal utility type - should not be referenceable due to exports field
23+
export interface InternalUtil { __private: never; }
24+
>InternalUtil : Symbol(InternalUtil, Decl(internal.d.ts, 0, 0))
25+
>__private : Symbol(InternalUtil.__private, Decl(internal.d.ts, 1, 31))
26+
27+
=== /node_modules/@base-lib/react/index.d.ts ===
28+
29+
export * from "../../.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts";
30+
31+
=== /src/component.ts ===
32+
import { Tooltip } from "@base-lib/react";
33+
>Tooltip : Symbol(Tooltip, Decl(component.ts, 0, 8))
34+
35+
// This function returns a value whose inferred type includes Tooltip with its internal types.
36+
// Without syntacticNodeBuilder, tsgo will:
37+
// 1. Analyze the function body to infer the return type
38+
// 2. Encounter Tooltip type which has __internal: InternalUtil
39+
// 3. Try to serialize InternalUtil type
40+
// 4. Fail to generate clean specifier (blocked by exports)
41+
// 5. Fall back to relative path through .pnpm directory
42+
// 6. With skipLibCheck, should suppress error instead of reporting TS2742
43+
export function createComponent() {
44+
>createComponent : Symbol(createComponent, Decl(component.ts, 0, 42))
45+
46+
return {
47+
data: Tooltip
48+
>data : Symbol(data, Decl(component.ts, 11, 10))
49+
>Tooltip : Symbol(Tooltip, Decl(component.ts, 0, 8))
50+
51+
};
52+
}
53+
54+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//// [tests/cases/compiler/declarationEmitPnpmWorkspaceSkipLibCheck.ts] ////
2+
3+
=== /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts ===
4+
export { Tooltip } from "./esm/Tooltip";
5+
>Tooltip : import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip").TooltipProps & { __internal: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal").InternalUtil; }
6+
7+
=== /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip.d.ts ===
8+
import { InternalUtil } from "./utils/internal";
9+
>InternalUtil : any
10+
11+
export interface TooltipProps { content: string; }
12+
>content : string
13+
14+
export declare const Tooltip: TooltipProps & { __internal: InternalUtil };
15+
>Tooltip : TooltipProps & { __internal: InternalUtil; }
16+
>__internal : InternalUtil
17+
18+
=== /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal.d.ts ===
19+
// Internal utility type - should not be referenceable due to exports field
20+
export interface InternalUtil { __private: never; }
21+
>__private : never
22+
23+
=== /node_modules/@base-lib/react/index.d.ts ===
24+
25+
export * from "../../.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts";
26+
27+
=== /src/component.ts ===
28+
import { Tooltip } from "@base-lib/react";
29+
>Tooltip : import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip").TooltipProps & { __internal: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal").InternalUtil; }
30+
31+
// This function returns a value whose inferred type includes Tooltip with its internal types.
32+
// Without syntacticNodeBuilder, tsgo will:
33+
// 1. Analyze the function body to infer the return type
34+
// 2. Encounter Tooltip type which has __internal: InternalUtil
35+
// 3. Try to serialize InternalUtil type
36+
// 4. Fail to generate clean specifier (blocked by exports)
37+
// 5. Fall back to relative path through .pnpm directory
38+
// 6. With skipLibCheck, should suppress error instead of reporting TS2742
39+
export function createComponent() {
40+
>createComponent : () => { data: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip").TooltipProps & { __internal: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal").InternalUtil; }; }
41+
42+
return {
43+
>{ data: Tooltip } : { data: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip").TooltipProps & { __internal: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal").InternalUtil; }; }
44+
45+
data: Tooltip
46+
>data : import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip").TooltipProps & { __internal: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal").InternalUtil; }
47+
>Tooltip : import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip").TooltipProps & { __internal: import("/node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal").InternalUtil; }
48+
49+
};
50+
}
51+
52+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// @strict: true
2+
// @declaration: true
3+
// @emitDeclarationOnly: true
4+
// @skipLibCheck: true
5+
// @moduleResolution: node16
6+
// @module: node16
7+
8+
// Test that skipLibCheck suppresses TS2742 errors for internal library types
9+
// when generating declarations in pnpm workspaces where package exports block
10+
// direct access to internal files.
11+
12+
// @Filename: /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/package.json
13+
{
14+
"name": "@base-lib/react",
15+
"version": "1.0.0",
16+
"exports": {
17+
".": "./index.d.ts"
18+
}
19+
}
20+
21+
// @Filename: /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts
22+
export { Tooltip } from "./esm/Tooltip";
23+
24+
// @Filename: /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/Tooltip.d.ts
25+
import { InternalUtil } from "./utils/internal";
26+
export interface TooltipProps { content: string; }
27+
export declare const Tooltip: TooltipProps & { __internal: InternalUtil };
28+
29+
// @Filename: /node_modules/.pnpm/@[email protected]/node_modules/@base-lib/react/esm/utils/internal.d.ts
30+
// Internal utility type - should not be referenceable due to exports field
31+
export interface InternalUtil { __private: never; }
32+
33+
// @Filename: /node_modules/@base-lib/react/package.json
34+
{
35+
"name": "@base-lib/react",
36+
"version": "1.0.0"
37+
}
38+
39+
// @Filename: /node_modules/@base-lib/react/index.d.ts
40+
export * from "../../.pnpm/@[email protected]/node_modules/@base-lib/react/index.d.ts";
41+
42+
// @Filename: /src/component.ts
43+
import { Tooltip } from "@base-lib/react";
44+
45+
// This function returns a value whose inferred type includes Tooltip with its internal types.
46+
// Without syntacticNodeBuilder, tsgo will:
47+
// 1. Analyze the function body to infer the return type
48+
// 2. Encounter Tooltip type which has __internal: InternalUtil
49+
// 3. Try to serialize InternalUtil type
50+
// 4. Fail to generate clean specifier (blocked by exports)
51+
// 5. Fall back to relative path through .pnpm directory
52+
// 6. With skipLibCheck, should suppress error instead of reporting TS2742
53+
export function createComponent() {
54+
return {
55+
data: Tooltip
56+
};
57+
}
58+

0 commit comments

Comments
 (0)