microsoft / microsoft/TypeScript

Comment directive activated when longer string used

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

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

Bug Domain: Parser
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

TypeScript Version: typescript@4.0.0-dev.20200526
NodeJS Version: v12.16.2
Visual Studio Code:

Version: 1.45.1 (system setup)
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:35.169Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 6.1.7601

Search Terms: comment directive, @ts-ignore

Code

let obj = { }
// @ts-ignoreThisShouldNotMatchButItDoes
console.log( `obj.a = ${obj.a}` )

Expected behavior:
Property 'a' does not exist on type 'object'.ts(2339)

Actual behavior:
compile time: no 2339 error or indication in VS Code
run time: obj.a = undefined

Description
Visual Studio code and running tsc will produce error 2339 when the comment directive is removed. When adding in the comment // @ts-ignore both Visual Studio code and tsc will ignore the error. However, misspelling ts-ignore as ts-ignoree or ts-ignoreThisShouldNotMatchButItDoes will invoke the @ts-ignore directive and ignore the error.

I didn't test other directives to see whether they had similar issues... trying to keep things simple, but this issue could be symptomatic of all comment directives, assuming they re-use the same code for parsing.

Playground Link: https://www.typescriptlang.org/play/?target=6&jsx=0&ssl=2&ssc=13&pln=2&pc=41#code/DYUwLgBA9gRgVhAvBA3hAvgKAPTYgATAGcBaASwHMA7KAJxABUALMogZSagFdgATAOShgAsgEMwAYyYAhLmACSYACJQQRTBKhUiUUADpgUCgAoIAA1hw9opBAAkKS9fRmIASkxA

Related Issues: None that I could find. Searched under @ts-ignore, comment directive

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

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

はじめの一歩

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

調査の方向性

issue のコードサンプルと Playground リンクに示されている TypeScript コンパイラーの動作を、報告されている TypeScript 4.0.0-dev.20200526 のセットアップで確認することから始めます。// @ts-ignoreThisShouldNotMatchButItDoes のケースを tsc で再現し、正しく記述されたディレクティブおよびスペルミスのあるバリエーションと比較します。完了条件は、正確なコメントディレクティブだけがエラー 2339 を抑制し、より長い文字列では抑制されないことです。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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