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

[ID-Prep] PR4 - Preserve types nodes from type assertions in declaration emit #57589

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
324 changes: 162 additions & 162 deletions src/compiler/transformers/declarations.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ var x = {};
//// [duplicatePropertiesInTypeAssertions01.d.ts]
declare let x: {
a: number;
a: number;
rbuckton marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class C {
readonly roFiled = null! as P;
method(p = null! as P) {}
methodWithRequiredDefault(p = null! as P, req: number) {}
methodWithRequiredDefault2(p = null! as P, req: number) {}

constructor(public ctorField = null! as P) {}
}
Expand Down Expand Up @@ -68,6 +67,26 @@ export class C {
reuseType7? = null! as `A` | `A`;
reuseType8? = null! as `${string}-ok` | `${string}-ok`;
reuseType9? = null! as this | this;
}

//// [angularAssertionToTypeReferences.ts]
type P = { } & { name: string }

export let vLet = <P>null!
export const vConst = <P>null!

export function fn(p = <P>null!) {}

export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}

export class C {
field = <P>null!
optField? = <P>null!
readonly roFiled = <P>null!;
method(p = <P>null!) {}
methodWithRequiredDefault(p = <P>null!, req: number) {}

constructor(public ctorField = <P>null!) {}
}

//// [assertToTypeReferences.js]
Expand Down Expand Up @@ -97,9 +116,6 @@ var C = /** @class */ (function () {
C.prototype.methodWithRequiredDefault = function (p, req) {
if (p === void 0) { p = null; }
};
C.prototype.methodWithRequiredDefault2 = function (p, req) {
if (p === void 0) { p = null; }
};
return C;
}());
exports.C = C;
Expand Down Expand Up @@ -169,6 +185,37 @@ var C = /** @class */ (function () {
return C;
}());
exports.C = C;
//// [angularAssertionToTypeReferences.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.C = exports.fnWithRequiredDefaultParam = exports.fn = exports.vConst = exports.vLet = void 0;
exports.vLet = null;
exports.vConst = null;
function fn(p) {
if (p === void 0) { p = null; }
}
exports.fn = fn;
function fnWithRequiredDefaultParam(p, req) {
if (p === void 0) { p = null; }
}
exports.fnWithRequiredDefaultParam = fnWithRequiredDefaultParam;
var C = /** @class */ (function () {
function C(ctorField) {
if (ctorField === void 0) { ctorField = null; }
this.ctorField = ctorField;
this.field = null;
this.optField = null;
this.roFiled = null;
}
C.prototype.method = function (p) {
if (p === void 0) { p = null; }
};
C.prototype.methodWithRequiredDefault = function (p, req) {
if (p === void 0) { p = null; }
};
return C;
}());
exports.C = C;


//// [assertToTypeReferences.d.ts]
Expand All @@ -185,7 +232,6 @@ export declare class C {
readonly roFiled: P;
method(p?: P): void;
methodWithRequiredDefault(p: P, req: number): void;
methodWithRequiredDefault2(p: P, req: number): void;
constructor(ctorField?: P);
}
declare const _default: {
Expand Down Expand Up @@ -256,3 +302,21 @@ export declare class C {
reuseType9?: this | this;
}
export {};
//// [angularAssertionToTypeReferences.d.ts]
type P = {} & {
name: string;
};
export declare let vLet: P;
export declare const vConst: P;
export declare function fn(p?: P): void;
export declare function fnWithRequiredDefaultParam(p: P, req: number): void;
export declare class C {
ctorField: P;
field: P;
optField?: P;
readonly roFiled: P;
method(p?: P): void;
methodWithRequiredDefault(p: P, req: number): void;
constructor(ctorField?: P);
}
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,8 @@ export class C {
>P : Symbol(P, Decl(assertToTypeReferences.ts, 0, 0))
>req : Symbol(req, Decl(assertToTypeReferences.ts, 13, 45))

methodWithRequiredDefault2(p = null! as P, req: number) {}
>methodWithRequiredDefault2 : Symbol(C.methodWithRequiredDefault2, Decl(assertToTypeReferences.ts, 13, 61))
>p : Symbol(p, Decl(assertToTypeReferences.ts, 14, 31))
>P : Symbol(P, Decl(assertToTypeReferences.ts, 0, 0))
>req : Symbol(req, Decl(assertToTypeReferences.ts, 14, 46))

constructor(public ctorField = null! as P) {}
>ctorField : Symbol(C.ctorField, Decl(assertToTypeReferences.ts, 16, 16))
>ctorField : Symbol(C.ctorField, Decl(assertToTypeReferences.ts, 15, 16))
>P : Symbol(P, Decl(assertToTypeReferences.ts, 0, 0))
}

Expand Down Expand Up @@ -190,3 +184,58 @@ export class C {
reuseType9? = null! as this | this;
>reuseType9 : Symbol(C.reuseType9, Decl(assertToOtherTypes.ts, 20, 59))
}

=== angularAssertionToTypeReferences.ts ===
type P = { } & { name: string }
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
>name : Symbol(name, Decl(angularAssertionToTypeReferences.ts, 0, 16))

export let vLet = <P>null!
>vLet : Symbol(vLet, Decl(angularAssertionToTypeReferences.ts, 2, 10))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

export const vConst = <P>null!
>vConst : Symbol(vConst, Decl(angularAssertionToTypeReferences.ts, 3, 12))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

export function fn(p = <P>null!) {}
>fn : Symbol(fn, Decl(angularAssertionToTypeReferences.ts, 3, 30))
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 5, 19))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}
>fnWithRequiredDefaultParam : Symbol(fnWithRequiredDefaultParam, Decl(angularAssertionToTypeReferences.ts, 5, 35))
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 7, 43))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
>req : Symbol(req, Decl(angularAssertionToTypeReferences.ts, 7, 56))

export class C {
>C : Symbol(C, Decl(angularAssertionToTypeReferences.ts, 7, 72))

field = <P>null!
>field : Symbol(C.field, Decl(angularAssertionToTypeReferences.ts, 9, 16))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

optField? = <P>null!
>optField : Symbol(C.optField, Decl(angularAssertionToTypeReferences.ts, 10, 20))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

readonly roFiled = <P>null!;
>roFiled : Symbol(C.roFiled, Decl(angularAssertionToTypeReferences.ts, 11, 24))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

method(p = <P>null!) {}
>method : Symbol(C.method, Decl(angularAssertionToTypeReferences.ts, 12, 32))
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 13, 11))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))

methodWithRequiredDefault(p = <P>null!, req: number) {}
>methodWithRequiredDefault : Symbol(C.methodWithRequiredDefault, Decl(angularAssertionToTypeReferences.ts, 13, 27))
>p : Symbol(p, Decl(angularAssertionToTypeReferences.ts, 14, 30))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
>req : Symbol(req, Decl(angularAssertionToTypeReferences.ts, 14, 43))

constructor(public ctorField = <P>null!) {}
>ctorField : Symbol(C.ctorField, Decl(angularAssertionToTypeReferences.ts, 16, 16))
>P : Symbol(P, Decl(angularAssertionToTypeReferences.ts, 0, 0))
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ export class C {
>p : { name: string; }
>null! as P : { name: string; }
>null! : null
>req : number

methodWithRequiredDefault2(p = null! as P, req: number) {}
>methodWithRequiredDefault2 : (p: { name: string; }, req: number) => void
>p : { name: string; }
>null! as P : { name: string; }
>null! : null
>req : number

constructor(public ctorField = null! as P) {}
Expand Down Expand Up @@ -236,3 +229,68 @@ export class C {
>null! as this | this : this
>null! : null
}

=== angularAssertionToTypeReferences.ts ===
type P = { } & { name: string }
>P : { name: string; }
>name : string

export let vLet = <P>null!
>vLet : { name: string; }
><P>null! : { name: string; }
>null! : null

export const vConst = <P>null!
>vConst : { name: string; }
><P>null! : { name: string; }
>null! : null

export function fn(p = <P>null!) {}
>fn : (p?: { name: string; }) => void
>p : { name: string; }
><P>null! : { name: string; }
>null! : null

export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}
>fnWithRequiredDefaultParam : (p: { name: string; }, req: number) => void
>p : { name: string; }
><P>null! : { name: string; }
>null! : null
>req : number

export class C {
>C : C

field = <P>null!
>field : { name: string; }
><P>null! : { name: string; }
>null! : null

optField? = <P>null!
>optField : { name: string; }
><P>null! : { name: string; }
>null! : null

readonly roFiled = <P>null!;
>roFiled : { name: string; }
><P>null! : { name: string; }
>null! : null

method(p = <P>null!) {}
>method : (p?: { name: string; }) => void
>p : { name: string; }
><P>null! : { name: string; }
>null! : null

methodWithRequiredDefault(p = <P>null!, req: number) {}
>methodWithRequiredDefault : (p: { name: string; }, req: number) => void
>p : { name: string; }
><P>null! : { name: string; }
>null! : null
>req : number

constructor(public ctorField = <P>null!) {}
>ctorField : { name: string; }
><P>null! : { name: string; }
>null! : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class C {
readonly roFiled = null! as P;
method(p = null! as P) {}
methodWithRequiredDefault(p = null! as P, req: number) {}
methodWithRequiredDefault2(p = null! as P, req: number) {}

constructor(public ctorField = null! as P) {}
}
Expand Down Expand Up @@ -68,6 +67,26 @@ export class C {
reuseType7? = null! as `A` | `A`;
reuseType8? = null! as `${string}-ok` | `${string}-ok`;
reuseType9? = null! as this | this;
}

//// [angularAssertionToTypeReferences.ts]
type P = { } & { name: string }

export let vLet = <P>null!
export const vConst = <P>null!

export function fn(p = <P>null!) {}

export function fnWithRequiredDefaultParam(p = <P>null!, req: number) {}

export class C {
field = <P>null!
optField? = <P>null!
readonly roFiled = <P>null!;
method(p = <P>null!) {}
methodWithRequiredDefault(p = <P>null!, req: number) {}

constructor(public ctorField = <P>null!) {}
}

//// [assertToTypeReferences.js]
Expand Down Expand Up @@ -97,9 +116,6 @@ var C = /** @class */ (function () {
C.prototype.methodWithRequiredDefault = function (p, req) {
if (p === void 0) { p = null; }
};
C.prototype.methodWithRequiredDefault2 = function (p, req) {
if (p === void 0) { p = null; }
};
return C;
}());
exports.C = C;
Expand Down Expand Up @@ -169,6 +185,37 @@ var C = /** @class */ (function () {
return C;
}());
exports.C = C;
//// [angularAssertionToTypeReferences.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.C = exports.fnWithRequiredDefaultParam = exports.fn = exports.vConst = exports.vLet = void 0;
exports.vLet = null;
exports.vConst = null;
function fn(p) {
if (p === void 0) { p = null; }
}
exports.fn = fn;
function fnWithRequiredDefaultParam(p, req) {
if (p === void 0) { p = null; }
}
exports.fnWithRequiredDefaultParam = fnWithRequiredDefaultParam;
var C = /** @class */ (function () {
function C(ctorField) {
if (ctorField === void 0) { ctorField = null; }
this.ctorField = ctorField;
this.field = null;
this.optField = null;
this.roFiled = null;
}
C.prototype.method = function (p) {
if (p === void 0) { p = null; }
};
C.prototype.methodWithRequiredDefault = function (p, req) {
if (p === void 0) { p = null; }
};
return C;
}());
exports.C = C;


//// [assertToTypeReferences.d.ts]
Expand All @@ -189,9 +236,6 @@ export declare class C {
methodWithRequiredDefault(p: {
name: string;
} | undefined, req: number): void;
methodWithRequiredDefault2(p: {
name: string;
} | undefined, req: number): void;
constructor(ctorField?: P);
}
declare const _default: {
Expand Down Expand Up @@ -262,3 +306,27 @@ export declare class C {
reuseType9?: this | this | undefined;
}
export {};
//// [angularAssertionToTypeReferences.d.ts]
type P = {} & {
name: string;
};
export declare let vLet: P;
export declare const vConst: P;
export declare function fn(p?: P): void;
export declare function fnWithRequiredDefaultParam(p: {
name: string;
} | undefined, req: number): void;
export declare class C {
ctorField: P;
field: P;
optField?: {
name: string;
} | undefined;
readonly roFiled: P;
method(p?: P): void;
methodWithRequiredDefault(p: {
name: string;
} | undefined, req: number): void;
constructor(ctorField?: P);
}
export {};
Loading
Loading