-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Ensure generated property names for methods named "new" are quoted #55750
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3286ba0
Fixed issue with method called `new` being emitted as construct signa…
Andarist 3825f0e
update baselines
Andarist 0145515
Merge remote-tracking branch 'origin/main' into fix/emit-dts-method-new
Andarist e759f9f
Merge branch 'main' into pr-55109-redo
jakebailey b96cd35
Undo fix
jakebailey 8e430b7
Use alternative fix that doesn't change emit
jakebailey 3e0b686
Add test for fixAddMissingMember, make it work correctly with a comment
jakebailey 81827b0
Tweak comment
jakebailey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idle observation: Lint rule for functions with optional parameters which are never not supplied? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better as some external pass, as ts-eslint doesn't really do stuff cross-project. Technically possible with the new ProjectService thing, maybe.