Category: vscode

[vscode] 儲存時自動修正程式碼格式

vscode 預設是沒有開啟儲存時自動呼叫 formatter 的自動修正格式功能 因此每次若要修正格式必須輸入 Format Document 的指令 若要開啟儲存時自動修正格式功能,可以在setting.json 新增此行 如果想更精確的指定特定語言才啟用,像是 javascript 可以用以下設定 參考資料: vscode 設定官方文件 針對特定語言的設定

[vscode] experimental support for decorators is a feature that is subject to change in a future release

在 visual studio code 使用 ES7 (ECMA Sciprt7) 的 decorator 時,可能會遇到 experimental support for decorators is a feature that is subject to change in a future release的語法錯誤提示 至於 decorator 是什麼在這篇就不多加介紹(可參考這篇),不過寫過 python 的人應該會有使用過。(目前 ES7 的 decorator 只支援 class) 這是因為預設 vscode 並不支援 decorator 的語法檢查,需要手動打開支援 decorator 的語法功能。 在 project 目錄創建 tsconfig.json 新增以下內容 重新開啟 vscode,就不會出現語法錯誤提示了!   參考資料: https://ihatetomatoes.net/how-to-remove-experimentaldecorators-warning-in-vscode/