mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
createPrivateIdentifier: names must start with # (#36506)
This commit is contained in:
parent
0cf100dcf8
commit
c42ef575be
@ -218,6 +218,9 @@ namespace ts {
|
||||
|
||||
// Private Identifiers
|
||||
export function createPrivateIdentifier(text: string): PrivateIdentifier {
|
||||
if (text[0] !== "#") {
|
||||
Debug.fail("First character of private identifier must be #: " + text);
|
||||
}
|
||||
const node = createSynthesizedNode(SyntaxKind.PrivateIdentifier) as PrivateIdentifier;
|
||||
node.escapedText = escapeLeadingUnderscores(text);
|
||||
return node;
|
||||
|
||||
@ -46,3 +46,8 @@ describe("Public APIs:: token to string", () => {
|
||||
assertDefinedTokenToString(ts.SyntaxKind.FirstKeyword, ts.SyntaxKind.LastKeyword);
|
||||
});
|
||||
});
|
||||
describe("Public APIs:: createPrivateIdentifier", () => {
|
||||
it("throws when name doesn't start with #", () => {
|
||||
assert.throw(() => ts.createPrivateIdentifier("not"), "Debug Failure. First character of private identifier must be #: not");
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user