emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/typescript-mode f9cd0dd539 112/222: Try parse new error-fo


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode f9cd0dd539 112/222: Try parse new error-format introduced in tsc 2.7+
Date: Sun, 6 Feb 2022 16:59:23 -0500 (EST)

branch: elpa/typescript-mode
commit f9cd0dd539d5d23f2b466de0cf20f9b0aef07258
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Try parse new error-format introduced in tsc 2.7+
    
    Add to compilation-mode.
    Tests.
    
    This hopefully fixes 
https://github.com/ananthakumaran/typescript.el/issues/77.
---
 typescript-mode-tests.el | 28 ++++++++++++++++++++++++++++
 typescript-mode.el       | 12 ++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
index 656553944d..2b77423017 100644
--- a/typescript-mode-tests.el
+++ b/typescript-mode-tests.el
@@ -620,6 +620,34 @@ const b = 'not terminated bbb")))
         (let ((typescript-autoconvert-to-template-flag t))
           (should-modify str delimiter))))))
 
+;; compilation-mode tests
+
+(ert-deftest recognizes-tsc-errors ()
+
+  (dolist (test-case
+           ;; typescript 2.6 and earlier
+           `(("test.ts(2,7): error TS2322: Type '2' is not assignable to type 
'string'."
+              ,typescript-tsc-error-regexp
+              "test.ts")
+
+             ;; typescript 2.7 and later
+             ("test.ts:2:7 - error TS2322: Type '2' is not assignable to type 
'string'."
+              ,typescript-tsc27-error-regexp
+              "test.ts")
+             ))
+    (let* ((text (car test-case))
+           (regexp    (cadr test-case))
+           (matched-file-name (cl-caddr test-case))
+           (times     1))
+      (with-temp-buffer
+        (insert text)
+        (goto-char (point-min))
+
+        (re-search-forward regexp)
+        (should
+         (equal matched-file-name (match-string 1)))))))
+
+
 (provide 'typescript-mode-tests)
 
 ;;; typescript-mode-tests.el ends here
diff --git a/typescript-mode.el b/typescript-mode.el
index 11627ab412..a3d92dbfac 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -2535,6 +2535,14 @@ the broken-down class name of the item to insert."
    "error [[:alnum:]]+: [^\r\n]+$")
   "Regexp to match errors generated by tsc.")
 
+;; handle compiler-errors like the following when doing M-x 
compile<ret>tsc<ret>
+;; test.ts:2:7 - error TS2322: Type '2' is not assignable to type 'string'.
+(defconst typescript-tsc27-error-regexp
+  (concat
+   "^[[:blank:]]*"
+   "\\([^(\r\n)]+\\):\\([0-9]+\\):\\([0-9]+\\) - [[:blank:]]*"
+   "error [[:alnum:]]+: [^\r\n]+$")
+  "Regexp to match errors generated by tsc.")
 ;;
 ;; Should handle output like:
 ;; src/modules/authenticator.ts[1, 83]: ' should be "
@@ -2577,6 +2585,10 @@ the broken-down class name of the item to insert."
         ,typescript-tsc-error-regexp
         1 2 3 2)
 
+       (typescript-tsc27
+        ,typescript-tsc27-error-regexp
+        1 2 3 2)
+
        (typescript-tslint
         ,typescript-tslint-report-regexp
         3 4 5 (1))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]