Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment directive activated when longer string used #38791

Open
houghtonap opened this issue May 26, 2020 · 1 comment
Open

Comment directive activated when longer string used #38791

houghtonap opened this issue May 26, 2020 · 1 comment
Labels
Bug A bug in TypeScript
Milestone

Comments

@houghtonap
Copy link

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

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jun 4, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 4, 2020
@RyanCavanaugh
Copy link
Member

I suspect we'll need to allow some delimiters; there's probably code like

// @ts-ignore: Doing something sketchy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants