Skip to content
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

Various fixes for valid code not being parsed properly #252

Merged
merged 6 commits into from
Jul 12, 2023
Merged

Various fixes for valid code not being parsed properly #252

merged 6 commits into from
Jul 12, 2023

Conversation

guillaumebrunerie
Copy link
Contributor

This pull request fixes five instances of valid code not being parsed correctly (mostly due to new or somewhat advanced features):

  • Support for the unique symbol type (see here):
const sym: unique symbol = Symbol();
  • Correct parsing of as const (it is currently being parsed as if const were a type, but it is a keyword):
const str = "foobar" as const;
declare const f: (x: any) => asserts x;
  • Support for const type parameters (see here):
const f = <const T extends string>(x: T) => x;
  • Support for extends clauses in infer (see here):
type StringAsNumber<T> = T extends `${infer N extends number}` ? N : never;

Checklist:

  • All tests pass in CI.
  • There are sufficient tests for the new fix/feature.
  • Grammar rules have not been renamed unless absolutely necessary.
  • The conflicts section hasn't grown too much.
  • The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).

common/define-grammar.js Show resolved Hide resolved
common/define-grammar.js Show resolved Hide resolved
@amaanq amaanq merged commit 6e695f4 into tree-sitter:master Jul 12, 2023
1 check passed
@amaanq
Copy link
Member

amaanq commented Jul 12, 2023

Thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants