Skip to content

Commit be5de2a

Browse files
Copilotjakebailey
andauthored
Fix declaration emit to remove non-JSDoc comments while preserving JSDoc (#1752)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jakebailey <[email protected]>
1 parent 78c7660 commit be5de2a

File tree

774 files changed

+1794
-11986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

774 files changed

+1794
-11986
lines changed

internal/compiler/emitter.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil
194194
// !!! strada skipped emit if there were diagnostics
195195

196196
printerOptions := printer.PrinterOptions{
197-
RemoveComments: options.RemoveComments.IsTrue(),
198-
NewLine: options.NewLine,
199-
NoEmitHelpers: options.NoEmitHelpers.IsTrue(),
200-
SourceMap: options.DeclarationMap.IsTrue(),
201-
InlineSourceMap: options.InlineSourceMap.IsTrue(),
202-
InlineSources: options.InlineSources.IsTrue(),
197+
RemoveComments: options.RemoveComments.IsTrue(),
198+
OnlyPrintJSDocStyle: true,
199+
NewLine: options.NewLine,
200+
NoEmitHelpers: options.NoEmitHelpers.IsTrue(),
201+
SourceMap: options.DeclarationMap.IsTrue(),
202+
InlineSourceMap: options.InlineSourceMap.IsTrue(),
203+
InlineSources: options.InlineSources.IsTrue(),
203204
// !!!
204205
}
205206

testdata/baselines/reference/compiler/parameterPropertyWithDefaultValueExtended.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,22 @@ export class PublicWithDefault {
6565

6666

6767
//// [parameterPropertyWithDefaultValueExtended.d.ts]
68-
// Test with default value - should not have undefined
6968
export declare class WithDefault {
7069
readonly timestamp: Date;
7170
constructor(timestamp?: Date);
7271
}
73-
// Test without default value but optional - should have undefined
7472
export declare class WithoutDefault {
7573
readonly timestamp?: Date | undefined;
7674
constructor(timestamp?: Date | undefined);
7775
}
78-
// Test with explicit undefined type - should keep it
7976
export declare class ExplicitUndefined {
8077
readonly timestamp: Date | undefined;
8178
constructor(timestamp?: Date | undefined);
8279
}
83-
// Test private parameter property with default value
8480
export declare class PrivateWithDefault {
8581
private timestamp;
8682
constructor(timestamp?: Date);
8783
}
88-
// Test public parameter property with default value
8984
export declare class PublicWithDefault {
9085
timestamp: Date;
9186
constructor(timestamp?: Date);

testdata/baselines/reference/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ export type ControllerClass = Constructor<any>;
4141
//// [usage.d.ts]
4242
import { ControllerClass } from './application';
4343
import { BindingKey } from '@loopback/context';
44-
export declare const CONTROLLER_CLASS: BindingKey<ControllerClass>; // line in question
44+
export declare const CONTROLLER_CLASS: BindingKey<ControllerClass>;

testdata/baselines/reference/conformance/jsdocVariadicInOverload.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ p.use(x, y, z);
9696

9797

9898
//// [typeTagForMultipleVariableDeclarations.d.ts]
99-
// based on code from unifiedjs/unified
10099
declare class Node {
101100
}
102101
/**

testdata/baselines/reference/submodule/compiler/anonClassDeclarationEmitIsAnon.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ declare const _default: {
9090
};
9191
};
9292
export default _default;
93-
// Simple class
9493
export declare class User {
9594
name: string;
9695
}
@@ -99,7 +98,6 @@ declare const TimestampedUser_base: {
9998
timestamp: number;
10099
};
101100
} & typeof User;
102-
// User that is Timestamped
103101
export declare class TimestampedUser extends TimestampedUser_base {
104102
constructor();
105103
}

testdata/baselines/reference/submodule/compiler/anonClassDeclarationEmitIsAnon.js.diff

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,4 @@
2626
+ name = '';
2727
}
2828
exports.User = User;
29-
// User that is Timestamped
30-
@@= skipped -47, +42 lines =@@
31-
};
32-
};
33-
export default _default;
34-
+// Simple class
35-
export declare class User {
36-
name: string;
37-
}
38-
@@= skipped -8, +9 lines =@@
39-
timestamp: number;
40-
};
41-
} & typeof User;
42-
+// User that is Timestamped
43-
export declare class TimestampedUser extends TimestampedUser_base {
44-
constructor();
45-
}
29+
// User that is Timestamped

testdata/baselines/reference/submodule/compiler/bigintWithLib.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,14 @@ new Intl.NumberFormat("fr").format(bigintVal);
122122

123123

124124
//// [bigintWithLib.d.ts]
125-
// Test BigInt functions
126125
declare let bigintVal: bigint;
127126
declare let stringVal: string;
128-
// Test BigInt64Array
129127
declare let bigIntArray: BigInt64Array;
130128
declare let len: number;
131129
declare let arrayBufferLike: ArrayBufferView;
132-
// Test BigUint64Array
133130
declare let bigUintArray: BigUint64Array;
134-
// Test added DataView methods
135131
declare const dataView: DataView<ArrayBuffer>;
136-
// Test emitted declarations files
137-
declare const w = 12n; // should emit as const w = 12n
138-
declare const x = -12n; // should emit as const x = -12n
139-
declare const y: 12n; // should emit type 12n
140-
declare let z: bigint; // should emit type bigint in declaration file
132+
declare const w = 12n;
133+
declare const x = -12n;
134+
declare const y: 12n;
135+
declare let z: bigint;

testdata/baselines/reference/submodule/compiler/bigintWithLib.js.diff

Lines changed: 0 additions & 26 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/circularBaseTypes.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ function f(m) {
2727

2828

2929
//// [circularBaseTypes.d.ts]
30-
// Repro from #38098
3130
type M<T> = {
3231
value: T;
3332
};
3433
interface M2 extends M<M3> {
3534
}
36-
type M3 = M2[keyof M2]; // Error
35+
type M3 = M2[keyof M2];
3736
declare function f(m: M3): any;
38-
// Repro from #32581
3937
type X<T> = {
4038
[K in keyof T]: string;
4139
} & {

testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,4 @@
88
-// Repro from #38098
99
; // Error
1010
function f(m) {
11-
return m.value;
12-
@@= skipped -9, +7 lines =@@
13-
14-
15-
//// [circularBaseTypes.d.ts]
16-
+// Repro from #38098
17-
type M<T> = {
18-
value: T;
19-
};
20-
interface M2 extends M<M3> {
21-
}
22-
-type M3 = M2[keyof M2];
23-
+type M3 = M2[keyof M2]; // Error
24-
declare function f(m: M3): any;
25-
+// Repro from #32581
26-
type X<T> = {
27-
[K in keyof T]: string;
28-
} & {
11+
return m.value;

0 commit comments

Comments
 (0)