Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/htmljs-parser-5-18.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@marko/language-tools": patch
"@marko/language-server": patch
---

Require htmljs-parser 5.18.0, which ends a type at a trailing `void`, reads a TypeScript `!` after an operand as a non-null assertion, reads `delete` as an operator, and reads types in scriptlets, so templates using them are no longer misparsed.
5 changes: 5 additions & 0 deletions .changeset/postfix-bang-type-void-highlighting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"marko-vscode": patch
---

Highlight attribute values the way the parser now reads them: a `!` directly after an operand (`x!`, `f()!`, `x!!`, `"s"!`) is a non-null assertion that ends the value, `void` in a tag variable's type no longer runs on into the next attribute, and `delete x` stays one value.
2 changes: 1 addition & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@marko/compiler": "^5.42.8",
"@marko/language-tools": "^2.7.0",
"axe-core": "^4.12.1",
"htmljs-parser": "^5.17.1",
"htmljs-parser": "^5.18.0",
"jsdom": "^29.1.1",
"marko": "^5.39.43",
"prettier": "^3.8.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/language-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"@luxass/strip-json-comments": "^1.4.0",
"@marko/compiler": "^5.42.8",
"htmljs-parser": "^5.17.1",
"htmljs-parser": "^5.18.0",
"relative-import-path": "^1.0.1"
},
"devDependencies": {
Expand Down
15 changes: 11 additions & 4 deletions packages/vscode/syntaxes/marko.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"name": "meta.marko-spread-attribute",
"contentName": "source.ts",
"begin": "(\\.\\.\\.)",
"end": "(?=[,;\\]]|/>|(?<=[^=>])(?:(?<!\\s)>|>(?!=))|(?<!^|[!~*%&^|?:]|[!~*%&^|?/<>+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))",
"end": "(?=[,;\\]]|/>|(?<=[^=>])(?:(?<!\\s)>|>(?!=))|(?<!^|[~*%&^|?:]|^!|^!!|[^\\w$)\\]\\\"'`!]!|[^\\w$)\\]\\\"'`!]!!|[^.$\\w]await!|[^.$\\w]async!|[^.$\\w]class!|[^.$\\w]function!|[^.$\\w]keyof!|[^.$\\w]new!|[^.$\\w]readonly!|[^.$\\w]infer!|[^.$\\w]typeof!|[^.$\\w]void!|[^.$\\w]delete!|[^.$\\w]in!|[^.$\\w]instanceof!|[!~*%&^|?/<>+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void|[^.$\\w]delete)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))",
"patterns": [{ "include": "#javascript-expression" }],
"beginCaptures": { "1": { "name": "keyword.operator.spread.marko" } }
},
Expand All @@ -128,7 +128,7 @@
"name": "meta.embedded.ts",
"contentName": "source.ts",
"begin": "\\s*(:?=)\\s*",
"end": "(?=[,;\\]]|/>|(?<=[^=>])(?:(?<!\\s)>|>(?!=))|(?<!^|[!~*%&^|?:]|[!~*%&^|?/<>+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))",
"end": "(?=[,;\\]]|/>|(?<=[^=>])(?:(?<!\\s)>|>(?!=))|(?<!^|[~*%&^|?:]|^!|^!!|[^\\w$)\\]\\\"'`!]!|[^\\w$)\\]\\\"'`!]!!|[^.$\\w]await!|[^.$\\w]async!|[^.$\\w]class!|[^.$\\w]function!|[^.$\\w]keyof!|[^.$\\w]new!|[^.$\\w]readonly!|[^.$\\w]infer!|[^.$\\w]typeof!|[^.$\\w]void!|[^.$\\w]delete!|[^.$\\w]in!|[^.$\\w]instanceof!|[!~*%&^|?/<>+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void|[^.$\\w]delete)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))",
"patterns": [{ "include": "#javascript-expression" }],
"beginCaptures": { "1": { "patterns": [{ "include": "source.ts" }] } }
},
Expand Down Expand Up @@ -643,7 +643,7 @@
{
"comment": "We must match the some expressions ourselves since otherwise the js grammar can overstep.",
"contentName": "source.ts",
"match": "(?:\\s*\\b(?:as|await|extends|in|instanceof|satisfies|keyof|new|typeof|void))+\\s+(?![:=/,;>])[a-zA-Z0-9_$@#]*",
"match": "(?:\\s*\\b(?:as|await|delete|extends|in|instanceof|satisfies|keyof|new|typeof|void))+\\s+(?![:=/,;>])[a-zA-Z0-9_$@#]*",
"captures": { "0": { "patterns": [{ "include": "source.ts" }] } }
},
{
Expand Down Expand Up @@ -763,9 +763,16 @@
{
"comment": "Match type",
"begin": "\\s*(:)(?!=)",
"end": "(?=[,;\\](]|/>|(?<=[^=>])(?:(?<!\\s)>|>(?!=))|(?<!^|[!~*%&^|?:]|[!~*%&^|?/<>+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))",
"end": "(?=[,;\\](]|/>|(?<=[^=>])(?:(?<!\\s)>|>(?!=))|(?<!^|[~*%&^|?:]|^!|^!!|[^\\w$)\\]\\\"'`!]!|[^\\w$)\\]\\\"'`!]!!|[^.$\\w]await!|[^.$\\w]async!|[^.$\\w]class!|[^.$\\w]function!|[^.$\\w]keyof!|[^.$\\w]new!|[^.$\\w]readonly!|[^.$\\w]infer!|[^.$\\w]typeof!|[^.$\\w]in!|[^.$\\w]instanceof!|[!~*%&^|?/<>+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof)\\s+(?![\\n{+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))",
"patterns": [
{ "include": "source.ts#type" },
{
"comment": "In a type `void` is the void type, so unlike the operator it takes no operand",
"match": "\\s*\\b(void)\\b",
"captures": {
"1": { "name": "support.type.primitive.ts" }
}
},
{ "include": "#javascript-expression" }
],
"beginCaptures": {
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading