Add support for const generics #42

Closed
opened 2024-12-02 15:33:03 +01:00 by SirPepe · 1 comment
SirPepe commented 2024-12-02 15:33:03 +01:00 (Migrated from github.com)

More wired syntax:

function doStuff<const T>(foo:T) {
  return foo;
}

doStuff([1, 2, 3]);

function doOtherStuff<const T extends any[]>(foo:T) {
  return foo;
}

doOtherStuff([1, 2, 3]);
doOtherStuff({ foo: 1 });

https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABAEzgZSiYwA8EEDOUiAKgHwAUwccAXCQJSIDeAUIogE4CmmnS1OAG5WAX1atUGLMAoBtAIwAaRACYVAZgC6DEa1CRYCFHADyUABbdO07HkLESibgA8o3MMgKIAhmACeclqUgvRMbBw8fAI0IuKSZpbWtrKKKuqI2roJ5lY2mNgUzIihiAqIorpAA

More wired syntax: ```typescript function doStuff<const T>(foo:T) { return foo; } doStuff([1, 2, 3]); function doOtherStuff<const T extends any[]>(foo:T) { return foo; } doOtherStuff([1, 2, 3]); doOtherStuff({ foo: 1 }); ``` https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABAEzgZSiYwA8EEDOUiAKgHwAUwccAXCQJSIDeAUIogE4CmmnS1OAG5WAX1atUGLMAoBtAIwAaRACYVAZgC6DEa1CRYCFHADyUABbdO07HkLESibgA8o3MMgKIAhmACeclqUgvRMbBw8fAI0IuKSZpbWtrKKKuqI2roJ5lY2mNgUzIihiAqIorpAA
marijnh commented 2024-12-02 15:43:33 +01:00 (Migrated from github.com)

It would be so great if the TypeScript project published a coherent grammar. But alas, they do not. Attached patch adds support for this notation.

It would be so great if the TypeScript project published a coherent grammar. But alas, they do not. Attached patch adds support for this notation.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/javascript#42
No description provided.