diff mbox series

[GSoC] userdiff: add funcname regex and wordregex for typescript language

Message ID 20240319185938.243667-1-utsavp0213@gmail.com (mailing list archive)
State New, archived
Headers show
Series [GSoC] userdiff: add funcname regex and wordregex for typescript language | expand

Commit Message

Utsav Parmar March 19, 2024, 6:59 p.m. UTC
This patch adds a builtin driver for typescript language supporting regex for both function name and words. Also updates the `.gitattributes.txt` to reflect this.

gitattributes: add typescript language to hunk headers support
t4034: add tests for typescript word_regex
t4018: add tests for typescript funcname regex
userdiff: add funcname regex and wordregex for typescript language

---

Comments

Patrick Steinhardt March 21, 2024, 12:21 p.m. UTC | #1
On Wed, Mar 20, 2024 at 12:29:38AM +0530, Utsav Parmar wrote:
> This patch adds a builtin driver for typescript language supporting regex for both function name and words. Also updates the `.gitattributes.txt` to reflect this.

Please be mindful that we typically wrap commit messages at 72 columns
per line. Furthermore, we don't typically say "This patch", but rather
use an imperative style. So instead of saying "This patch adds a biultin
driver", we'd say "Add a builtin driver".

> gitattributes: add typescript language to hunk headers support
> t4034: add tests for typescript word_regex
> t4018: add tests for typescript funcname regex
> userdiff: add funcname regex and wordregex for typescript language

We don't usually provide such bulleted-list-style changes for each of
the files. In this case, it shoul be fine to say something "Add tests
and documentation for the new driver".

Last but not least, this message is missing your signoff.

I would recommend you to read "Documentation/MyFirstContribution.txt",
which explains all of this.

I can't really say much regarding the remainder of your changes given
that I'm neither familiar with "userdiff.c" nor with TypeScript. I hope
that others can chime in here.

Patrick

> ---
> Index: userdiff.c
> diff --git a/userdiff.c b/userdiff.c
> --- a/userdiff.c	(revision 2953d95d402b6bff1a59c4712f4d46f1b9ea137f)
> +++ b/userdiff.c	(revision 6724df99624834d9b7278a0bc95fa319f526a1fe)
> @@ -297,6 +297,22 @@
>  	 "|([^][)(}{[ \t])+"),
>  PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
>  	 "\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
> +PATTERNS("typescript",
> +         "^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n"
> +         /* Method definitions */
> +         "^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$",
> +         /* -- */
> +         "[a-zA-Z_][a-zA-Z0-9_]*"
> +         /* Integers and floats */
> +         "|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"
> +         /* Binary */
> +         "|0[bB][01]+"
> +         /* Hexadecimals */
> +         "|0[xX][0-9a-fA-F]+"
> +         /* Floats starting with a decimal point */
> +         "|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?"
> +         /* Operators */
> +         "[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~"),
>  { "default", NULL, NULL, -1, { NULL, 0 } },
>  };
>  #undef PATTERNS
> Index: t/t4018/typescript-arrow-function
> diff --git a/t/t4018/typescript-arrow-function b/t/t4018/typescript-arrow-function
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-arrow-function	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,4 @@
> +const RIGHT = (one) => {
> +    someMethodCall();
> +    return ChangeMe;
> +}
> Index: t/t4018/typescript-class-member-function
> diff --git a/t/t4018/typescript-class-member-function b/t/t4018/typescript-class-member-function
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-class-member-function	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,7 @@
> +class Test {
> +	var one;
> +	function RIGHT(two: string) {
> +		someMethodCall();
> +		return ChangeMe;
> +	}
> +}
> Index: t/t4018/typescript-enum
> diff --git a/t/t4018/typescript-enum b/t/t4018/typescript-enum
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-enum	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,6 @@
> +enum RIGHT {
> +    ONE = 1,
> +    TWO,
> +    THREE,
> +    ChangeMe
> +}
> Index: t/t4018/typescript-function
> diff --git a/t/t4018/typescript-function b/t/t4018/typescript-function
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-function	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,4 @@
> +function RIGHT<Type implements AnotherType>(one: number): Type {
> +    someMethodCall();
> +    return ChangeMe;
> +}
> Index: t/t4018/typescript-function-assignment
> diff --git a/t/t4018/typescript-function-assignment b/t/t4018/typescript-function-assignment
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-function-assignment	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,4 @@
> +const RIGHT = function(one: number): Type {
> +    someMethodCall();
> +    return ChangeMe;
> +}
> Index: t/t4018/typescript-interface
> diff --git a/t/t4018/typescript-interface b/t/t4018/typescript-interface
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-interface	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,4 @@
> +interface RIGHT {
> +  one?: string;
> +  [propName: ChangeMe]: any;
> +}
> \ No newline at end of file
> Index: t/t4018/typescript-type
> diff --git a/t/t4018/typescript-type b/t/t4018/typescript-type
> new file mode 100644
> --- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4018/typescript-type	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> @@ -0,0 +1,4 @@
> +type RIGHT = {
> +  one: number,
> +  ChangeMe: CustomType
> +}
> \ No newline at end of file
> Index: t/t4034-diff-words.sh
> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
> --- a/t/t4034-diff-words.sh	(revision b60d253ea78063d444f7131c3100388a7cdac060)
> +++ b/t/t4034-diff-words.sh	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> @@ -338,6 +338,7 @@
>  test_language_driver ruby
>  test_language_driver scheme
>  test_language_driver tex
> +test_language_driver typescript
>  
>  test_expect_success 'word-diff with diff.sbe' '
>  	cat >pre <<-\EOF &&
> Index: t/t4034/typescript/expect
> diff --git a/t/t4034/typescript/expect b/t/t4034/typescript/expect
> new file mode 100644
> --- /dev/null	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> +++ b/t/t4034/typescript/expect	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> @@ -0,0 +1,57 @@
> +<BOLD>diff --git a/pre b/post<RESET>
> +<BOLD>index e4a51a2..9c56465 100644<RESET>
> +<BOLD>--- a/pre<RESET>
> +<BOLD>+++ b/post<RESET>
> +<CYAN>@@ -1,16 +1,16 @@<RESET>
> +log("Hello World<RED>!\n<RESET><GREEN>?<RESET>")
> +<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>'
> +!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>&<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>^<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>|<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>&&<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>||<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
> +<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b
> +<RESET>
> +<RED>a<RESET><GREEN>y
> +<RESET>
> +<GREEN>x<RESET>,y
> Index: t/t4034/typescript/post
> diff --git a/t/t4034/typescript/post b/t/t4034/typescript/post
> new file mode 100644
> --- /dev/null	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> +++ b/t/t4034/typescript/post	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> @@ -0,0 +1,16 @@
> +log("Hello World?")
> +(1) (-1e10) (0xabcdef) u'y'
> +!x ~x x++ x-- x*y x&y
> +x*y x/y x%y
> +x+y x-y
> +x<<y x>>y
> +x<y x<=y x>y x>=y
> +x==y x!=y
> +x&y
> +x^y
> +x|y
> +x&&y
> +x||y
> +x?y:z
> +x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y
> +x,y
> Index: t/t4034/typescript/pre
> diff --git a/t/t4034/typescript/pre b/t/t4034/typescript/pre
> new file mode 100644
> --- /dev/null	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> +++ b/t/t4034/typescript/pre	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> @@ -0,0 +1,16 @@
> +log("Hello World!\n")
> +1 -1e10 0xabcdef 'x'
> +!a ~a a++ a-- a*b a&b
> +a*b a/b a%b
> +a+b a-b
> +a<<b a>>b
> +a<b a<=b a>b a>=b
> +a==b a!=b
> +a&b
> +a^b
> +a|b
> +a&&b
> +a||b
> +a?b:z
> +a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b
> +a,y
> Index: Documentation/gitattributes.txt
> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> --- a/Documentation/gitattributes.txt	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
> +++ b/Documentation/gitattributes.txt	(revision 2891f81b087a3f1c89d1417c40ba576aaa30feb9)
> @@ -902,6 +902,8 @@
>  
>  - `tex` suitable for source code for LaTeX documents.
>  
> +- `typescript` suitable for source code for TypeScript language.
> +
>  
>  Customizing word diff
>  ^^^^^^^^^^^^^^^^^^^^^
>
Utsav Parmar March 23, 2024, 3:07 p.m. UTC | #2
> Please be mindful that we typically wrap commit messages at 72 columns per line. Furthermore, we don't typically say "This patch", but rather use an imperative style. So instead of saying "This patch adds a biultin driver", we'd say "Add a builtin driver".

Thank you, I'll keep this in mind. Although that wasn't the intended
commit message.
I tried to create a single patch out of the 4 recent commits and send
it via email and this is how it came across. So, the 4 lines after
that are the actual commit messages.

> > gitattributes: add typescript language to hunk headers support
> > t4034: add tests for typescript word_regex
> > t4018: add tests for typescript funcname regex
> > userdiff: add funcname regex and wordregex for typescript language

> We don't usually provide such bulleted-list-style changes for each of the files. In this case, it shoul be fine to say something "Add tests and documentation for the new driver".

These are the original commit messages ':|. I apologize, I'm still new
to using a command line mailer, so please bear with me. I'm learning
how to use this well. On a side note, is there a mailer that you'd
recommend?

> Last but not least, this message is missing your signoff.

I believe I made a blunder while creating a patch file since the
commits are signed locally. I'll take extra care to review my mails
before sending from now onwards. Thank you for your direction.

I'll submit a follow up version with patches for each commit.
Patrick Steinhardt March 25, 2024, 7:33 a.m. UTC | #3
On Sat, Mar 23, 2024 at 08:18:57PM +0530, Utsav Parmar wrote:
[snip]
> > We don't usually provide such bulleted-list-style changes for each of the
> > files. In this case, it shoul be fine to say something "Add tests and
> > documentation for the new driver".
> 
> These are the original commit messages ':|. I apologize, I'm still new with
> using a command line mailer, so please bare with me. I'm learning how to
> use this well. On a side note, is there a mailer that you'd recommend?

This is of course very much a matter of taste, but I myself any many
other folks use mutt or NeoMutt to access mails from the command line.
Others may use for example Emacs or Alpine. If I were you I'd have a
look at the alternatives that exist and then decide for yourself which
one is most likely to be a good fit for you.

Patrick
diff mbox series

Patch

Index: userdiff.c
diff --git a/userdiff.c b/userdiff.c
--- a/userdiff.c	(revision 2953d95d402b6bff1a59c4712f4d46f1b9ea137f)
+++ b/userdiff.c	(revision 6724df99624834d9b7278a0bc95fa319f526a1fe)
@@ -297,6 +297,22 @@ 
 	 "|([^][)(}{[ \t])+"),
 PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
 	 "\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
+PATTERNS("typescript",
+         "^[ \t]*((enum|interface|type)[ \t]+([a-zA-Z][a-zA-Z0-9]*)+.*)$\n"
+         /* Method definitions */
+         "^[ \t]*[a-z]+[ \t]+([A-Za-z_][A-Za-z_0-9]*)+([ \t]*=[ \t]*(function)?)?([ \t]*[A-Za-z_<>&][?&<>|.,A-Za-z_]*[ \t]*)*[ \t]*\\([^;]*$",
+         /* -- */
+         "[a-zA-Z_][a-zA-Z0-9_]*"
+         /* Integers and floats */
+         "|[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"
+         /* Binary */
+         "|0[bB][01]+"
+         /* Hexadecimals */
+         "|0[xX][0-9a-fA-F]+"
+         /* Floats starting with a decimal point */
+         "|[-+]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][-+]?[0-9]+)?"
+         /* Operators */
+         "[-+*/%&|^!=<>]=?|===|!==|<<=?|>>=?|&&|\\|\\||\\?\\?|\\+\\+|--|~"),
 { "default", NULL, NULL, -1, { NULL, 0 } },
 };
 #undef PATTERNS
Index: t/t4018/typescript-arrow-function
diff --git a/t/t4018/typescript-arrow-function b/t/t4018/typescript-arrow-function
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-arrow-function	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,4 @@ 
+const RIGHT = (one) => {
+    someMethodCall();
+    return ChangeMe;
+}
Index: t/t4018/typescript-class-member-function
diff --git a/t/t4018/typescript-class-member-function b/t/t4018/typescript-class-member-function
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-class-member-function	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,7 @@ 
+class Test {
+	var one;
+	function RIGHT(two: string) {
+		someMethodCall();
+		return ChangeMe;
+	}
+}
Index: t/t4018/typescript-enum
diff --git a/t/t4018/typescript-enum b/t/t4018/typescript-enum
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-enum	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,6 @@ 
+enum RIGHT {
+    ONE = 1,
+    TWO,
+    THREE,
+    ChangeMe
+}
Index: t/t4018/typescript-function
diff --git a/t/t4018/typescript-function b/t/t4018/typescript-function
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-function	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,4 @@ 
+function RIGHT<Type implements AnotherType>(one: number): Type {
+    someMethodCall();
+    return ChangeMe;
+}
Index: t/t4018/typescript-function-assignment
diff --git a/t/t4018/typescript-function-assignment b/t/t4018/typescript-function-assignment
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-function-assignment	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,4 @@ 
+const RIGHT = function(one: number): Type {
+    someMethodCall();
+    return ChangeMe;
+}
Index: t/t4018/typescript-interface
diff --git a/t/t4018/typescript-interface b/t/t4018/typescript-interface
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-interface	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,4 @@ 
+interface RIGHT {
+  one?: string;
+  [propName: ChangeMe]: any;
+}
\ No newline at end of file
Index: t/t4018/typescript-type
diff --git a/t/t4018/typescript-type b/t/t4018/typescript-type
new file mode 100644
--- /dev/null	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4018/typescript-type	(revision b60d253ea78063d444f7131c3100388a7cdac060)
@@ -0,0 +1,4 @@ 
+type RIGHT = {
+  one: number,
+  ChangeMe: CustomType
+}
\ No newline at end of file
Index: t/t4034-diff-words.sh
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
--- a/t/t4034-diff-words.sh	(revision b60d253ea78063d444f7131c3100388a7cdac060)
+++ b/t/t4034-diff-words.sh	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
@@ -338,6 +338,7 @@ 
 test_language_driver ruby
 test_language_driver scheme
 test_language_driver tex
+test_language_driver typescript
 
 test_expect_success 'word-diff with diff.sbe' '
 	cat >pre <<-\EOF &&
Index: t/t4034/typescript/expect
diff --git a/t/t4034/typescript/expect b/t/t4034/typescript/expect
new file mode 100644
--- /dev/null	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
+++ b/t/t4034/typescript/expect	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
@@ -0,0 +1,57 @@ 
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index e4a51a2..9c56465 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
+<CYAN>@@ -1,16 +1,16 @@<RESET>
+log("Hello World<RED>!\n<RESET><GREEN>?<RESET>")
+<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>) u<RESET>'<RED>x<RESET><GREEN>y<RESET>'
+!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>&<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>^<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>|<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>&&<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>||<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
+<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b
+<RESET>
+<RED>a<RESET><GREEN>y
+<RESET>
+<GREEN>x<RESET>,y
Index: t/t4034/typescript/post
diff --git a/t/t4034/typescript/post b/t/t4034/typescript/post
new file mode 100644
--- /dev/null	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
+++ b/t/t4034/typescript/post	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
@@ -0,0 +1,16 @@ 
+log("Hello World?")
+(1) (-1e10) (0xabcdef) u'y'
+!x ~x x++ x-- x*y x&y
+x*y x/y x%y
+x+y x-y
+x<<y x>>y
+x<y x<=y x>y x>=y
+x==y x!=y
+x&y
+x^y
+x|y
+x&&y
+x||y
+x?y:z
+x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y
+x,y
Index: t/t4034/typescript/pre
diff --git a/t/t4034/typescript/pre b/t/t4034/typescript/pre
new file mode 100644
--- /dev/null	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
+++ b/t/t4034/typescript/pre	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
@@ -0,0 +1,16 @@ 
+log("Hello World!\n")
+1 -1e10 0xabcdef 'x'
+!a ~a a++ a-- a*b a&b
+a*b a/b a%b
+a+b a-b
+a<<b a>>b
+a<b a<=b a>b a>=b
+a==b a!=b
+a&b
+a^b
+a|b
+a&&b
+a||b
+a?b:z
+a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b
+a,y
Index: Documentation/gitattributes.txt
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
--- a/Documentation/gitattributes.txt	(revision be6b88ac5ca33921af60ee42f71397011efb1806)
+++ b/Documentation/gitattributes.txt	(revision 2891f81b087a3f1c89d1417c40ba576aaa30feb9)
@@ -902,6 +902,8 @@ 
 
 - `tex` suitable for source code for LaTeX documents.
 
+- `typescript` suitable for source code for TypeScript language.
+
 
 Customizing word diff
 ^^^^^^^^^^^^^^^^^^^^^