-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure generated property names for methods named "new" are quoted (#…
…55750) Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
1 parent
b3770e7
commit 9cbcf01
Showing
22 changed files
with
365 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//// [tests/cases/compiler/emitMethodCalledNew.ts] //// | ||
|
||
//// [emitMethodCalledNew.ts] | ||
// https://github.com/microsoft/TypeScript/issues/55075 | ||
|
||
export const a = { | ||
new(x: number) { return x + 1 } | ||
} | ||
export const b = { | ||
"new"(x: number) { return x + 1 } | ||
} | ||
export const c = { | ||
["new"](x: number) { return x + 1 } | ||
} | ||
|
||
|
||
//// [emitMethodCalledNew.js] | ||
"use strict"; | ||
// https://github.com/microsoft/TypeScript/issues/55075 | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.c = exports.b = exports.a = void 0; | ||
exports.a = { | ||
new: function (x) { return x + 1; } | ||
}; | ||
exports.b = { | ||
"new": function (x) { return x + 1; } | ||
}; | ||
exports.c = (_a = {}, | ||
_a["new"] = function (x) { return x + 1; }, | ||
_a); | ||
|
||
|
||
//// [emitMethodCalledNew.d.ts] | ||
export declare const a: { | ||
"new"(x: number): number; | ||
}; | ||
export declare const b: { | ||
"new"(x: number): number; | ||
}; | ||
export declare const c: { | ||
"new"(x: number): number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//// [tests/cases/compiler/emitMethodCalledNew.ts] //// | ||
|
||
=== emitMethodCalledNew.ts === | ||
// https://github.com/microsoft/TypeScript/issues/55075 | ||
|
||
export const a = { | ||
>a : Symbol(a, Decl(emitMethodCalledNew.ts, 2, 12)) | ||
|
||
new(x: number) { return x + 1 } | ||
>new : Symbol(new, Decl(emitMethodCalledNew.ts, 2, 18)) | ||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 3, 6)) | ||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 3, 6)) | ||
} | ||
export const b = { | ||
>b : Symbol(b, Decl(emitMethodCalledNew.ts, 5, 12)) | ||
|
||
"new"(x: number) { return x + 1 } | ||
>"new" : Symbol("new", Decl(emitMethodCalledNew.ts, 5, 18)) | ||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 6, 8)) | ||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 6, 8)) | ||
} | ||
export const c = { | ||
>c : Symbol(c, Decl(emitMethodCalledNew.ts, 8, 12)) | ||
|
||
["new"](x: number) { return x + 1 } | ||
>["new"] : Symbol(["new"], Decl(emitMethodCalledNew.ts, 8, 18)) | ||
>"new" : Symbol(["new"], Decl(emitMethodCalledNew.ts, 8, 18)) | ||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 9, 10)) | ||
>x : Symbol(x, Decl(emitMethodCalledNew.ts, 9, 10)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//// [tests/cases/compiler/emitMethodCalledNew.ts] //// | ||
|
||
=== emitMethodCalledNew.ts === | ||
// https://github.com/microsoft/TypeScript/issues/55075 | ||
|
||
export const a = { | ||
>a : { "new"(x: number): number; } | ||
>{ new(x: number) { return x + 1 }} : { "new"(x: number): number; } | ||
|
||
new(x: number) { return x + 1 } | ||
>new : (x: number) => number | ||
>x : number | ||
>x + 1 : number | ||
>x : number | ||
>1 : 1 | ||
} | ||
export const b = { | ||
>b : { "new"(x: number): number; } | ||
>{ "new"(x: number) { return x + 1 }} : { "new"(x: number): number; } | ||
|
||
"new"(x: number) { return x + 1 } | ||
>"new" : (x: number) => number | ||
>x : number | ||
>x + 1 : number | ||
>x : number | ||
>1 : 1 | ||
} | ||
export const c = { | ||
>c : { "new"(x: number): number; } | ||
>{ ["new"](x: number) { return x + 1 }} : { "new"(x: number): number; } | ||
|
||
["new"](x: number) { return x + 1 } | ||
>["new"] : (x: number) => number | ||
>"new" : "new" | ||
>x : number | ||
>x + 1 : number | ||
>x : number | ||
>1 : 1 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.