Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 7 additions & 6 deletions internal/compiler/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,13 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil
// !!! strada skipped emit if there were diagnostics

printerOptions := printer.PrinterOptions{
RemoveComments: options.RemoveComments.IsTrue(),
NewLine: options.NewLine,
NoEmitHelpers: options.NoEmitHelpers.IsTrue(),
SourceMap: options.DeclarationMap.IsTrue(),
InlineSourceMap: options.InlineSourceMap.IsTrue(),
InlineSources: options.InlineSources.IsTrue(),
RemoveComments: options.RemoveComments.IsTrue(),
OnlyPrintJSDocStyle: true,
NewLine: options.NewLine,
NoEmitHelpers: options.NoEmitHelpers.IsTrue(),
SourceMap: options.DeclarationMap.IsTrue(),
InlineSourceMap: options.InlineSourceMap.IsTrue(),
InlineSources: options.InlineSources.IsTrue(),
// !!!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,22 @@ export class PublicWithDefault {


//// [parameterPropertyWithDefaultValueExtended.d.ts]
// Test with default value - should not have undefined
export declare class WithDefault {
readonly timestamp: Date;
constructor(timestamp?: Date);
}
// Test without default value but optional - should have undefined
export declare class WithoutDefault {
readonly timestamp?: Date | undefined;
constructor(timestamp?: Date | undefined);
}
// Test with explicit undefined type - should keep it
export declare class ExplicitUndefined {
readonly timestamp: Date | undefined;
constructor(timestamp?: Date | undefined);
}
// Test private parameter property with default value
export declare class PrivateWithDefault {
private timestamp;
constructor(timestamp?: Date);
}
// Test public parameter property with default value
export declare class PublicWithDefault {
timestamp: Date;
constructor(timestamp?: Date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ export type ControllerClass = Constructor<any>;
//// [usage.d.ts]
import { ControllerClass } from './application';
import { BindingKey } from '@loopback/context';
export declare const CONTROLLER_CLASS: BindingKey<ControllerClass>; // line in question
export declare const CONTROLLER_CLASS: BindingKey<ControllerClass>;
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ p.use(x, y, z);


//// [typeTagForMultipleVariableDeclarations.d.ts]
// based on code from unifiedjs/unified
declare class Node {
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ declare const _default: {
};
};
export default _default;
// Simple class
export declare class User {
name: string;
}
Expand All @@ -99,7 +98,6 @@ declare const TimestampedUser_base: {
timestamp: number;
};
} & typeof User;
// User that is Timestamped
export declare class TimestampedUser extends TimestampedUser_base {
constructor();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,4 @@
+ name = '';
}
exports.User = User;
// User that is Timestamped
@@= skipped -47, +42 lines =@@
};
};
export default _default;
+// Simple class
export declare class User {
name: string;
}
@@= skipped -8, +9 lines =@@
timestamp: number;
};
} & typeof User;
+// User that is Timestamped
export declare class TimestampedUser extends TimestampedUser_base {
constructor();
}
// User that is Timestamped
13 changes: 4 additions & 9 deletions testdata/baselines/reference/submodule/compiler/bigintWithLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,14 @@ new Intl.NumberFormat("fr").format(bigintVal);


//// [bigintWithLib.d.ts]
// Test BigInt functions
declare let bigintVal: bigint;
declare let stringVal: string;
// Test BigInt64Array
declare let bigIntArray: BigInt64Array;
declare let len: number;
declare let arrayBufferLike: ArrayBufferView;
// Test BigUint64Array
declare let bigUintArray: BigUint64Array;
// Test added DataView methods
declare const dataView: DataView<ArrayBuffer>;
// Test emitted declarations files
declare const w = 12n; // should emit as const w = 12n
declare const x = -12n; // should emit as const x = -12n
declare const y: 12n; // should emit type 12n
declare let z: bigint; // should emit type bigint in declaration file
declare const w = 12n;
declare const x = -12n;
declare const y: 12n;
declare let z: bigint;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ function f(m) {


//// [circularBaseTypes.d.ts]
// Repro from #38098
type M<T> = {
value: T;
};
interface M2 extends M<M3> {
}
type M3 = M2[keyof M2]; // Error
type M3 = M2[keyof M2];
declare function f(m: M3): any;
// Repro from #32581
type X<T> = {
[K in keyof T]: string;
} & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,4 @@
-// Repro from #38098
; // Error
function f(m) {
return m.value;
@@= skipped -9, +7 lines =@@


//// [circularBaseTypes.d.ts]
+// Repro from #38098
type M<T> = {
value: T;
};
interface M2 extends M<M3> {
}
-type M3 = M2[keyof M2];
+type M3 = M2[keyof M2]; // Error
declare function f(m: M3): any;
+// Repro from #32581
type X<T> = {
[K in keyof T]: string;
} & {
return m.value;
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class e {

//// [classdecl.d.ts]
declare class a {
//constructor ();
constructor(n: number);
constructor(s: string);
pgF(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,4 @@
+ pv3;
foo(ns) {
return ns.toString();
}
@@= skipped -44, +45 lines =@@

//// [classdecl.d.ts]
declare class a {
+ //constructor ();
constructor(n: number);
constructor(s: string);
pgF(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ declare function foo<T>(x: {
}, f: (arg: {
kind: T;
}) => void): void;
// Repro from #45603
interface Action<TName extends string, TPayload> {
name: TName;
payload: TPayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@
foo(a, fab);
foo(b, fab);
const actionA = { payload: 'any-string' };
@@= skipped -28, +27 lines =@@
}, f: (arg: {
kind: T;
}) => void): void;
+// Repro from #45603
interface Action<TName extends string, TPayload> {
name: TName;
payload: TPayload;
@@= skipped -7, +8 lines =@@
@@= skipped -35, +34 lines =@@
declare const actionA: Action<"ACTION_A", string>;
declare const actionB: Action<"ACTION_B", boolean>;
declare function call<TName extends string, TPayload>(action: Action<TName, TPayload>, fn: (action: Action<TName, TPayload>) => any): void;
Expand Down
16 changes: 5 additions & 11 deletions testdata/baselines/reference/submodule/compiler/commentsClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ class c9 {
//// [commentsClass.d.ts]
/** This is class c2 without constuctor*/
declare class c2 {
} // trailing comment1
}
declare var i2: c2;
declare var i2_c: typeof c2;
declare class c3 {
/** Constructor comment*/
constructor(); // trailing comment of constructor
} /* trailing comment 2 */
constructor();
}
declare var i3: c3;
declare var i3_c: typeof c3;
/** Class comment*/
declare class c4 {
/** Constructor comment*/
constructor(); /* trailing comment of constructor 2*/
constructor();
}
declare var i4: c4;
declare var i4_c: typeof c4;
Expand All @@ -168,20 +168,14 @@ declare class c5 {
}
declare var i5: c5;
declare var i5_c: typeof c5;
/// class with statics and constructor
declare class c6 {
/// s1 comment
static s1: number; /// s1 comment2
/// constructor comment
static s1: number;
constructor();
}
declare var i6: c6;
declare var i6_c: typeof c6;
// class with statics and constructor
declare class c7 {
// s1 comment
static s1: number;
// constructor comment
constructor();
}
declare var i7: c7;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,4 @@
+ static s1; /** s1 comment2 */
/** constructor comment
*/
constructor() {
@@= skipped -20, +22 lines =@@
//// [commentsClass.d.ts]
/** This is class c2 without constuctor*/
declare class c2 {
-}
+} // trailing comment1
declare var i2: c2;
declare var i2_c: typeof c2;
declare class c3 {
/** Constructor comment*/
- constructor();
-}
+ constructor(); // trailing comment of constructor
+} /* trailing comment 2 */
declare var i3: c3;
declare var i3_c: typeof c3;
/** Class comment*/
declare class c4 {
/** Constructor comment*/
- constructor();
+ constructor(); /* trailing comment of constructor 2*/
}
declare var i4: c4;
declare var i4_c: typeof c4;
@@= skipped -22, +22 lines =@@
}
declare var i5: c5;
declare var i5_c: typeof c5;
+/// class with statics and constructor
declare class c6 {
- static s1: number;
+ /// s1 comment
+ static s1: number; /// s1 comment2
+ /// constructor comment
constructor();
}
declare var i6: c6;
declare var i6_c: typeof c6;
+// class with statics and constructor
declare class c7 {
+ // s1 comment
static s1: number;
+ // constructor comment
constructor();
}
declare var i7: c7;
constructor() {
Loading
Loading