I am using Emacs with org-babel mode to insert the TypeScript code example in my org-mode document.
The elisp I have added in .emacs.d/init.el is as follows:
(eval-after-load "org" '(org-babel-do-load-languages 'org-babel-load-languages '((typescript . t))))
(require 'typescript-mode)
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
(require 'tide)
Now, I want to make the following code as error:
#+BEGIN_SRC typescript :results output
let data_1: string = undefined;
let data_2: string = null;
#+END_SRC
I think I can make it by specifying tsconfig.json as:
{
"compilerOptions": {
"strictNullChecks": true,
},
}
But where can I put tsconfig.json?
I modified ~/.emacs.d/elpa/tide-20200327.1218/tsserver/tsconfig.json and restarded Emacs but nothing changed.
I ran tsc from the command line and confirmed tsconfig.json works as expected.
Thank you.
To make the code you've mentioned display an error, you can use the
:cmdlineparameter. That allows you to pass command line parameters (such as--strictNullChecks) directly totsc:I don't think you can use
tsconfig.jsonto configure this, because to evaluate the code block, emacs first saves the code to a temp file (e.g./tmp/babel-5NJb2Q/ob-input-Afjtyu) and then runs thetscon it (see ob-typescript.el). That temp file bears no relation to yourtsconfig.json.