Skip to content
Permalink
Browse files
TSX: Removed parameter token (#3090)
  • Loading branch information
RunDevelopment committed Sep 26, 2021
1 parent 2f9672a commit 0a313f4f9d38247812d41e99dffa120efcfdf623
Showing with 72 additions and 48 deletions.
  1. +3 −0 components/prism-tsx.js
  2. +1 −1 components/prism-tsx.min.js
  3. +37 −47 tests/languages/tsx/issue2594.test
  4. +31 −0 tests/languages/tsx/issue3089.test
@@ -2,6 +2,9 @@
var typescript = Prism.util.clone(Prism.languages.typescript);
Prism.languages.tsx = Prism.languages.extend('jsx', typescript);

// doesn't work with TS because TS is too complex
delete Prism.languages.tsx['parameter'];

// This will prevent collisions between TSX tags and TS generic types.
// Idea by https://github.com/karlhorky
// Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928

Some generated files are not rendered by default. Learn more.

@@ -31,11 +31,9 @@ export default function Form() {
["keyword", "function"],
["function", "Add1"],
["punctuation", "("],
["parameter", [
"a",
["punctuation", ","],
" b"
]],
"a",
["punctuation", ","],
" b",
["punctuation", ")"],
["punctuation", "{"],
["keyword", "return"],
@@ -57,9 +55,7 @@ export default function Form() {
["punctuation", "}"],

["keyword", "type"],
["class-name", [
"Bar"
]],
["class-name", ["Bar"]],
["operator", "="],
" Foo",
["operator", "<"],
@@ -70,11 +66,9 @@ export default function Form() {
["keyword", "function"],
["function", "Add2"],
["punctuation", "("],
["parameter", [
"a",
["punctuation", ","],
" b"
]],
"a",
["punctuation", ","],
" b",
["punctuation", ")"],
["punctuation", "{"],
["keyword", "return"],
@@ -98,37 +92,36 @@ export default function Form() {
["keyword", "function"],
["function", "handleSubmit"],
["punctuation", "("],
["parameter", [
"event",
["operator", ":"],
" FormEvent",
["operator", "<"],
"HTMLFormElement",
["operator", ">"]
]],
"event",
["operator", ":"],
" FormEvent",
["operator", "<"],
"HTMLFormElement",
["operator", ">"],
["punctuation", ")"],
["punctuation", "{"],

"\r\n event",
["punctuation", "."],
["function", "preventDefault"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],

["punctuation", "}"],

["keyword", "function"],
["function", "handleChange"],
["punctuation", "("],
["parameter", [
"event",
["operator", ":"],
" ChangeEvent",
["operator", "<"],
"HTMLInputElement",
["operator", ">"]
]],
"event",
["operator", ":"],
" ChangeEvent",
["operator", "<"],
"HTMLInputElement",
["operator", ">"],
["punctuation", ")"],
["punctuation", "{"],

["builtin", "console"],
["punctuation", "."],
["function", "log"],
@@ -140,18 +133,18 @@ export default function Form() {
"value",
["punctuation", ")"],
["punctuation", ";"],

["punctuation", "}"],

["keyword", "function"],
["function", "handleClick"],
["punctuation", "("],
["parameter", [
"event",
["operator", ":"],
" MouseEvent"
]],
"event",
["operator", ":"],
" MouseEvent",
["punctuation", ")"],
["punctuation", "{"],

["builtin", "console"],
["punctuation", "."],
["function", "log"],
@@ -161,6 +154,7 @@ export default function Form() {
"button",
["punctuation", ")"],
["punctuation", ";"],

["punctuation", "}"],

["keyword", "export"],
@@ -170,16 +164,16 @@ export default function Form() {
["punctuation", "("],
["punctuation", ")"],
["punctuation", "{"],

["keyword", "return"],
["punctuation", "("],

["tag", [
["tag", [
["punctuation", "<"],
"form"
]],
["attr-name", [
"onSubmit"
]],
["attr-name", ["onSubmit"]],
["script", [
["script-punctuation", "="],
["punctuation", "{"],
@@ -194,18 +188,14 @@ export default function Form() {
["punctuation", "<"],
"input"
]],
["attr-name", [
"onChange"
]],
["attr-name", ["onChange"]],
["script", [
["script-punctuation", "="],
["punctuation", "{"],
"handleChange",
["punctuation", "}"]
]],
["attr-name", [
"placeholder"
]],
["attr-name", ["placeholder"]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
@@ -220,9 +210,7 @@ export default function Form() {
["punctuation", "<"],
"button"
]],
["attr-name", [
"onClick"
]],
["attr-name", ["onClick"]],
["script", [
["script-punctuation", "="],
["punctuation", "{"],
@@ -246,7 +234,9 @@ export default function Form() {
]],
["punctuation", ">"]
]],

["punctuation", ")"],
["punctuation", ";"],

["punctuation", "}"]
]
]
@@ -0,0 +1,31 @@
// react tsx
function log(msg: string): void {
console.log(msg);
}

----------------------------------------------------

[
["comment", "// react tsx"],

["keyword", "function"],
["function", "log"],
["punctuation", "("],
"msg",
["operator", ":"],
["builtin", "string"],
["punctuation", ")"],
["operator", ":"],
["keyword", "void"],
["punctuation", "{"],

["builtin", "console"],
["punctuation", "."],
["function", "log"],
["punctuation", "("],
"msg",
["punctuation", ")"],
["punctuation", ";"],

["punctuation", "}"]
]

0 comments on commit 0a313f4

Please sign in to comment.