microsoft / microsoft/TypeScript

Ignore Specific Error [AGAIN]

オープン
#38,409 コメント 7 件 リアクション 25 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Yes, this is a duplicate of #11051, but that issue is closed and this NEEDS to be addressed.

People use Typescript for more than just Javascript compilation now. There are tons of transpilers that convert TS to all sorts of useful languages. Typescript must have a proper way to disable certain error codes project-wide.

My specific issue right now is that I'm using TypescriptToLua, a Typescript transpiler that produces lua code, and Typescript throws a fit whenever I try to use mathematical operators on classes. This would make sense if I was compiling to Javascript, but I'm not, but I'm forced to annotate every line with @ts-ignore (unrealistic) or suffer through constant reports of TS2362 and TS2363 in my console (infuriating).

There could easily be an ignoreErrors: number[] in the .tsconfig file that provides this functionality. The only thing stopping it from existing is stubborness. Well designed errors that never cause issues are a nice dream, but realistically there will always be use cases that are not met by the error handler, and the user should have the power to suppress invalid warnings.

A short example of my issue:

Typescript that will be converted using TypescriptToLua:

/** @customConstructor vector.new */
declare class Vector {
	constructor(x: number, y?: number, z?: number);
}

const v = new Vector(1, 2, 3);
const vSquared = v * v;

Generated (valid) lua code:

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
v = vector.new(1, 2, 3)
vSquared = v * v

Obnoxious compiler output:

main.ts:9:18 - error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

9 const vSquared = v * v;
                   ~

main.ts:9:22 - error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

9 const vSquared = v * v;
                       ~

Thank you for your time, I hope that this issue can be seen as what is is, which is a frustrating lack of user control and agency.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

TypeScript の tsconfig コンパイラオプションと診断の処理を確認し、まず要求されているプロジェクト全体での TS2362 と TS2363 の抑制から始めます。クローズされた重複 issue #11051 と比較してください。完了の定義は、行ごとの @ts-ignore を必要とせずに選択した診断コードを抑制する、合意済みの設定メカニズムを定義して実装することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。