Skip to content

Commit 3833bf5

Browse files
Incorporated feedback
1 parent c84eeb0 commit 3833bf5

9 files changed

+569
-203
lines changed

src/compiler/transformers/declarations.ts

Lines changed: 162 additions & 162 deletions
Large diffs are not rendered by default.

tests/baselines/reference/duplicatePropertiesInTypeAssertions01.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ var x = {};
1010
//// [duplicatePropertiesInTypeAssertions01.d.ts]
1111
declare let x: {
1212
a: number;
13+
a: number;
1314
};

tests/baselines/reference/verbatim-declarations-assertions(strict=false).js

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class C {
1515
readonly roFiled = null! as P;
1616
method(p = null! as P) {}
1717
methodWithRequiredDefault(p = null! as P, req: number) {}
18-
methodWithRequiredDefault2(p = null! as P, req: number) {}
1918

2019
constructor(public ctorField = null! as P) {}
2120
}
@@ -68,6 +67,26 @@ export class C {
6867
reuseType7? = null! as `A` | `A`;
6968
reuseType8? = null! as `${string}-ok` | `${string}-ok`;
7069
reuseType9? = null! as this | this;
70+
}
71+
72+
//// [angularAssertionToTypeReferences.ts]
73+
type P = { } & { name: string }
74+
75+
export let vLet = <P>null!
76+
export const vConst = <P>null!
77+
78+
export function fn(p = <P>null!) {}
79+
80+
export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}
81+
82+
export class C {
83+
field = <P>null!
84+
optField? = <P>null!
85+
readonly roFiled = <P>null!;
86+
method(p = <P>null!) {}
87+
methodWithRequiredDefault(p = <P>null!, req: number) {}
88+
89+
constructor(public ctorField = <P>null!) {}
7190
}
7291

7392
//// [assertToTypeReferences.js]
@@ -97,9 +116,6 @@ var C = /** @class */ (function () {
97116
C.prototype.methodWithRequiredDefault = function (p, req) {
98117
if (p === void 0) { p = null; }
99118
};
100-
C.prototype.methodWithRequiredDefault2 = function (p, req) {
101-
if (p === void 0) { p = null; }
102-
};
103119
return C;
104120
}());
105121
exports.C = C;
@@ -169,6 +185,37 @@ var C = /** @class */ (function () {
169185
return C;
170186
}());
171187
exports.C = C;
188+
//// [angularAssertionToTypeReferences.js]
189+
"use strict";
190+
Object.defineProperty(exports, "__esModule", { value: true });
191+
exports.C = exports.fnWithRequiredDefaultParam = exports.fn = exports.vConst = exports.vLet = void 0;
192+
exports.vLet = null;
193+
exports.vConst = null;
194+
function fn(p) {
195+
if (p === void 0) { p = null; }
196+
}
197+
exports.fn = fn;
198+
function fnWithRequiredDefaultParam(p, req) {
199+
if (p === void 0) { p = null; }
200+
}
201+
exports.fnWithRequiredDefaultParam = fnWithRequiredDefaultParam;
202+
var C = /** @class */ (function () {
203+
function C(ctorField) {
204+
if (ctorField === void 0) { ctorField = null; }
205+
this.ctorField = ctorField;
206+
this.field = null;
207+
this.optField = null;
208+
this.roFiled = null;
209+
}
210+
C.prototype.method = function (p) {
211+
if (p === void 0) { p = null; }
212+
};
213+
C.prototype.methodWithRequiredDefault = function (p, req) {
214+
if (p === void 0) { p = null; }
215+
};
216+
return C;
217+
}());
218+
exports.C = C;
172219

173220

174221
//// [assertToTypeReferences.d.ts]
@@ -185,7 +232,6 @@ export declare class C {
185232
readonly roFiled: P;
186233
method(p?: P): void;
187234
methodWithRequiredDefault(p: P, req: number): void;
188-
methodWithRequiredDefault2(p: P, req: number): void;
189235
constructor(ctorField?: P);
190236
}
191237
declare const _default: {
@@ -256,3 +302,21 @@ export declare class C {
256302
reuseType9?: this | this;
257303
}
258304
export {};
305+
//// [angularAssertionToTypeReferences.d.ts]
306+
type P = {} & {
307+
name: string;
308+
};
309+
export declare let vLet: P;
310+
export declare const vConst: P;
311+
export declare function fn(p?: P): void;
312+
export declare function fnWithRequiredDefaultParam(p: P, req: number): void;
313+
export declare class C {
314+
ctorField: P;
315+
field: P;
316+
optField?: P;
317+
readonly roFiled: P;
318+
method(p?: P): void;
319+
methodWithRequiredDefault(p: P, req: number): void;
320+
constructor(ctorField?: P);
321+
}
322+
export {};

tests/baselines/reference/verbatim-declarations-assertions(strict=false).symbols

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,8 @@ export class C {
4646
>P : Symbol(P, Decl(assertToTypeReferences.ts, 0, 0))
4747
>req : Symbol(req, Decl(assertToTypeReferences.ts, 13, 45))
4848

49-
methodWithRequiredDefault2(p = null! as P, req: number) {}
50-
>methodWithRequiredDefault2 : Symbol(C.methodWithRequiredDefault2, Decl(assertToTypeReferences.ts, 13, 61))
51-
>p : Symbol(p, Decl(assertToTypeReferences.ts, 14, 31))
52-
>P : Symbol(P, Decl(assertToTypeReferences.ts, 0, 0))
53-
>req : Symbol(req, Decl(assertToTypeReferences.ts, 14, 46))
54-
5549
constructor(public ctorField = null! as P) {}
56-
>ctorField : Symbol(C.ctorField, Decl(assertToTypeReferences.ts, 16, 16))
50+
>ctorField : Symbol(C.ctorField, Decl(assertToTypeReferences.ts, 15, 16))
5751
>P : Symbol(P, Decl(assertToTypeReferences.ts, 0, 0))
5852
}
5953

@@ -190,3 +184,58 @@ export class C {
190184
reuseType9? = null! as this | this;
191185
>reuseType9 : Symbol(C.reuseType9, Decl(assertToOtherTypes.ts, 20, 59))
192186
}
187+
188+
=== angularAssertionToTypeReferences.ts ===
189+
type P = { } & { name: string }
190+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
191+
>name : Symbol(name, Decl(angularAssertionToTypeReferences.ts, 0, 16))
192+
193+
export let vLet = <P>null!
194+
>vLet : Symbol(vLet, Decl(angularAssertionToTypeReferences.ts, 2, 10))
195+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
196+
197+
export const vConst = <P>null!
198+
>vConst : Symbol(vConst, Decl(angularAssertionToTypeReferences.ts, 3, 12))
199+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
200+
201+
export function fn(p = <P>null!) {}
202+
>fn : Symbol(fn, Decl(angularAssertionToTypeReferences.ts, 3, 30))
203+
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 5, 19))
204+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
205+
206+
export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}
207+
>fnWithRequiredDefaultParam : Symbol(fnWithRequiredDefaultParam, Decl(angularAssertionToTypeReferences.ts, 5, 35))
208+
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 7, 43))
209+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
210+
>req : Symbol(req, Decl(angularAssertionToTypeReferences.ts, 7, 56))
211+
212+
export class C {
213+
>C : Symbol(C, Decl(angularAssertionToTypeReferences.ts, 7, 72))
214+
215+
field = <P>null!
216+
>field : Symbol(C.field, Decl(angularAssertionToTypeReferences.ts, 9, 16))
217+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
218+
219+
optField? = <P>null!
220+
>optField : Symbol(C.optField, Decl(angularAssertionToTypeReferences.ts, 10, 20))
221+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
222+
223+
readonly roFiled = <P>null!;
224+
>roFiled : Symbol(C.roFiled, Decl(angularAssertionToTypeReferences.ts, 11, 24))
225+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
226+
227+
method(p = <P>null!) {}
228+
>method : Symbol(C.method, Decl(angularAssertionToTypeReferences.ts, 12, 32))
229+
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 13, 11))
230+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
231+
232+
methodWithRequiredDefault(p = <P>null!, req: number) {}
233+
>methodWithRequiredDefault : Symbol(C.methodWithRequiredDefault, Decl(angularAssertionToTypeReferences.ts, 13, 27))
234+
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 14, 30))
235+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
236+
>req : Symbol(req, Decl(angularAssertionToTypeReferences.ts, 14, 43))
237+
238+
constructor(public ctorField = <P>null!) {}
239+
>ctorField : Symbol(C.ctorField, Decl(angularAssertionToTypeReferences.ts, 16, 16))
240+
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
241+
}

tests/baselines/reference/verbatim-declarations-assertions(strict=false).types

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ export class C {
5252
>p : { name: string; }
5353
>null! as P : { name: string; }
5454
>null! : null
55-
>req : number
56-
57-
methodWithRequiredDefault2(p = null! as P, req: number) {}
58-
>methodWithRequiredDefault2 : (p: { name: string; }, req: number) => void
59-
>p : { name: string; }
60-
>null! as P : { name: string; }
61-
>null! : null
6255
>req : number
6356

6457
constructor(public ctorField = null! as P) {}
@@ -236,3 +229,68 @@ export class C {
236229
>null! as this | this : this
237230
>null! : null
238231
}
232+
233+
=== angularAssertionToTypeReferences.ts ===
234+
type P = { } & { name: string }
235+
>P : { name: string; }
236+
>name : string
237+
238+
export let vLet = <P>null!
239+
>vLet : { name: string; }
240+
><P>null! : { name: string; }
241+
>null! : null
242+
243+
export const vConst = <P>null!
244+
>vConst : { name: string; }
245+
><P>null! : { name: string; }
246+
>null! : null
247+
248+
export function fn(p = <P>null!) {}
249+
>fn : (p?: { name: string; }) => void
250+
>p : { name: string; }
251+
><P>null! : { name: string; }
252+
>null! : null
253+
254+
export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}
255+
>fnWithRequiredDefaultParam : (p: { name: string; }, req: number) => void
256+
>p : { name: string; }
257+
><P>null! : { name: string; }
258+
>null! : null
259+
>req : number
260+
261+
export class C {
262+
>C : C
263+
264+
field = <P>null!
265+
>field : { name: string; }
266+
><P>null! : { name: string; }
267+
>null! : null
268+
269+
optField? = <P>null!
270+
>optField : { name: string; }
271+
><P>null! : { name: string; }
272+
>null! : null
273+
274+
readonly roFiled = <P>null!;
275+
>roFiled : { name: string; }
276+
><P>null! : { name: string; }
277+
>null! : null
278+
279+
method(p = <P>null!) {}
280+
>method : (p?: { name: string; }) => void
281+
>p : { name: string; }
282+
><P>null! : { name: string; }
283+
>null! : null
284+
285+
methodWithRequiredDefault(p = <P>null!, req: number) {}
286+
>methodWithRequiredDefault : (p: { name: string; }, req: number) => void
287+
>p : { name: string; }
288+
><P>null! : { name: string; }
289+
>null! : null
290+
>req : number
291+
292+
constructor(public ctorField = <P>null!) {}
293+
>ctorField : { name: string; }
294+
><P>null! : { name: string; }
295+
>null! : null
296+
}

tests/baselines/reference/verbatim-declarations-assertions(strict=true).js

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class C {
1515
readonly roFiled = null! as P;
1616
method(p = null! as P) {}
1717
methodWithRequiredDefault(p = null! as P, req: number) {}
18-
methodWithRequiredDefault2(p = null! as P, req: number) {}
1918

2019
constructor(public ctorField = null! as P) {}
2120
}
@@ -68,6 +67,26 @@ export class C {
6867
reuseType7? = null! as `A` | `A`;
6968
reuseType8? = null! as `${string}-ok` | `${string}-ok`;
7069
reuseType9? = null! as this | this;
70+
}
71+
72+
//// [angularAssertionToTypeReferences.ts]
73+
type P = { } & { name: string }
74+
75+
export let vLet = <P>null!
76+
export const vConst = <P>null!
77+
78+
export function fn(p = <P>null!) {}
79+
80+
export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}
81+
82+
export class C {
83+
field = <P>null!
84+
optField? = <P>null!
85+
readonly roFiled = <P>null!;
86+
method(p = <P>null!) {}
87+
methodWithRequiredDefault(p = <P>null!, req: number) {}
88+
89+
constructor(public ctorField = <P>null!) {}
7190
}
7291

7392
//// [assertToTypeReferences.js]
@@ -97,9 +116,6 @@ var C = /** @class */ (function () {
97116
C.prototype.methodWithRequiredDefault = function (p, req) {
98117
if (p === void 0) { p = null; }
99118
};
100-
C.prototype.methodWithRequiredDefault2 = function (p, req) {
101-
if (p === void 0) { p = null; }
102-
};
103119
return C;
104120
}());
105121
exports.C = C;
@@ -169,6 +185,37 @@ var C = /** @class */ (function () {
169185
return C;
170186
}());
171187
exports.C = C;
188+
//// [angularAssertionToTypeReferences.js]
189+
"use strict";
190+
Object.defineProperty(exports, "__esModule", { value: true });
191+
exports.C = exports.fnWithRequiredDefaultParam = exports.fn = exports.vConst = exports.vLet = void 0;
192+
exports.vLet = null;
193+
exports.vConst = null;
194+
function fn(p) {
195+
if (p === void 0) { p = null; }
196+
}
197+
exports.fn = fn;
198+
function fnWithRequiredDefaultParam(p, req) {
199+
if (p === void 0) { p = null; }
200+
}
201+
exports.fnWithRequiredDefaultParam = fnWithRequiredDefaultParam;
202+
var C = /** @class */ (function () {
203+
function C(ctorField) {
204+
if (ctorField === void 0) { ctorField = null; }
205+
this.ctorField = ctorField;
206+
this.field = null;
207+
this.optField = null;
208+
this.roFiled = null;
209+
}
210+
C.prototype.method = function (p) {
211+
if (p === void 0) { p = null; }
212+
};
213+
C.prototype.methodWithRequiredDefault = function (p, req) {
214+
if (p === void 0) { p = null; }
215+
};
216+
return C;
217+
}());
218+
exports.C = C;
172219

173220

174221
//// [assertToTypeReferences.d.ts]
@@ -189,9 +236,6 @@ export declare class C {
189236
methodWithRequiredDefault(p: {
190237
name: string;
191238
} | undefined, req: number): void;
192-
methodWithRequiredDefault2(p: {
193-
name: string;
194-
} | undefined, req: number): void;
195239
constructor(ctorField?: P);
196240
}
197241
declare const _default: {
@@ -262,3 +306,27 @@ export declare class C {
262306
reuseType9?: this | this | undefined;
263307
}
264308
export {};
309+
//// [angularAssertionToTypeReferences.d.ts]
310+
type P = {} & {
311+
name: string;
312+
};
313+
export declare let vLet: P;
314+
export declare const vConst: P;
315+
export declare function fn(p?: P): void;
316+
export declare function fnWithRequiredDefaultParam(p: {
317+
name: string;
318+
} | undefined, req: number): void;
319+
export declare class C {
320+
ctorField: P;
321+
field: P;
322+
optField?: {
323+
name: string;
324+
} | undefined;
325+
readonly roFiled: P;
326+
method(p?: P): void;
327+
methodWithRequiredDefault(p: {
328+
name: string;
329+
} | undefined, req: number): void;
330+
constructor(ctorField?: P);
331+
}
332+
export {};

0 commit comments

Comments
 (0)