add TypeScript keywords + future reserved keywords #11

Closed
leoortizz wants to merge 1 commit from add-keywords into main
leoortizz commented 2023-07-05 02:43:59 +02:00 (Migrated from github.com)

add the following keywords:

  • enum
  • implements
  • interface
  • package
  • private
  • protected
  • public
  • type

@marijnh I think that ideally some should be TypeScript only, also some should be scoped to the strict mode per the spec, but that would require greater changes. In the meantime I think that these should be added sooner rather than later as currently they can't be styled.

add the following keywords: - `enum` - `implements` - `interface` - `package` - `private` - `protected` - `public` - `type` @marijnh I think that ideally some should be TypeScript only, also some should be scoped to the strict mode [per the spec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#future_reserved_words), but that would require greater changes. In the meantime I think that these should be added sooner rather than later as currently they can't be styled.
marijnh commented 2023-07-05 10:14:13 +02:00 (Migrated from github.com)

I think that these should be added sooner rather than later as currently they can't be styled.

What does that mean? If you turn on TypeScript, these should all be highlighted correctly. Adding them as completions does not affect whether they are styled or not.

Attached patch adds this in a way where it only takes effect when TypeScript is actually enabled, and using snippets where appropriate.

> I think that these should be added sooner rather than later as currently they can't be styled. What does that mean? If you turn on TypeScript, these should all be highlighted correctly. Adding them as completions does not affect whether they are styled or not. Attached patch adds this in a way where it only takes effect when TypeScript is actually enabled, and using snippets where appropriate.
leoortizz commented 2023-07-05 16:39:30 +02:00 (Migrated from github.com)

I think that these should be added sooner rather than later as currently they can't be styled.

What does that mean? If you turn on TypeScript, these should all be highlighted correctly. Adding them as completions does not affect whether they are styled or not.

I'm defining my own syntax highlighting styles with syntaxHighlighting(HighlightStyle.define(TagStyle[])), then using tags as {tag: tags.keyword, color: 'var(--code-keyword)'}.

I meant that before this change these keywords were being identified as something else, then we had to style them as something else, not keywords as they are.

Attached patch adds this in a way where it only takes effect when TypeScript is actually enabled, and using snippets where appropriate.

Thanks!

> > I think that these should be added sooner rather than later as currently they can't be styled. > > What does that mean? If you turn on TypeScript, these should all be highlighted correctly. Adding them as completions does not affect whether they are styled or not. I'm defining my own syntax highlighting styles with `syntaxHighlighting(HighlightStyle.define(TagStyle[]))`, then using tags as `{tag: tags.keyword, color: 'var(--code-keyword)'}`. I meant that before this change these keywords were being identified as something else, then we had to style them as something else, not keywords as they are. > Attached patch adds this in a way where it only takes effect when TypeScript is actually enabled, and using snippets where appropriate. Thanks!
marijnh commented 2023-07-05 16:44:54 +02:00 (Migrated from github.com)

I meant that before this change these keywords were being identified as something else, then we had to style them as something else, not keywords as they are.

Right. But that's not accurate (that array you changed has no effect at all on the parse tree or highlighting).

> I meant that before this change these keywords were being identified as something else, then we had to style them as something else, not keywords as they are. Right. But that's not accurate (that array you changed has no effect at all on the parse tree or highlighting).

Pull request closed

Sign in to join this conversation.
No reviewers
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
codemirror/lang-javascript!11
No description provided.