Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c42ef57

Browse filesBrowse files
authored
createPrivateIdentifier: names must start with # (microsoft#36506)
1 parent 0cf100d commit c42ef57
Copy full SHA for c42ef57

File tree

Expand file treeCollapse file tree

2 files changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-0
lines changed

‎src/compiler/factoryPublic.ts

Copy file name to clipboardExpand all lines: src/compiler/factoryPublic.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ namespace ts {
218218

219219
// Private Identifiers
220220
export function createPrivateIdentifier(text: string): PrivateIdentifier {
221+
if (text[0] !== "#") {
222+
Debug.fail("First character of private identifier must be #: " + text);
223+
}
221224
const node = createSynthesizedNode(SyntaxKind.PrivateIdentifier) as PrivateIdentifier;
222225
node.escapedText = escapeLeadingUnderscores(text);
223226
return node;

‎src/testRunner/unittests/publicApi.ts

Copy file name to clipboardExpand all lines: src/testRunner/unittests/publicApi.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ describe("Public APIs:: token to string", () => {
4646
assertDefinedTokenToString(ts.SyntaxKind.FirstKeyword, ts.SyntaxKind.LastKeyword);
4747
});
4848
});
49+
describe("Public APIs:: createPrivateIdentifier", () => {
50+
it("throws when name doesn't start with #", () => {
51+
assert.throw(() => ts.createPrivateIdentifier("not"), "Debug Failure. First character of private identifier must be #: not");
52+
});
53+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.