String literal highlighting in TypeScript wrong end brace
Reported by
roger@versluis.ca,
Dec 19 2016
|
|||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36 OPR/42.0.2393.85
Steps to reproduce the problem:
1. Run following typescript code:
export class Class2 {
}
export class Class1 implements Class2 {
private test1(test: string): void {
return null;
}
public async test2(): Promise<void> {
console.log('destroying tables');
for (let i = 0; i < 1; i++) {
const assignment = i;
const line = `Test [${assignment}]`;
let a = 0;
}
console.log('another log');
}
}
Open the dev tools / sources and check the file.
What is the expected behavior?
The string literal part on line 17 should just highlight Test [${assignment}]
What went wrong?
It is highlighting the rest of the file instead.
When clicking on the last curly brace after the word assignment it thinks that this is the closing brace for the for loop, which is incorrect.
This only seems to happen when in a scope inside a function, inside a class that implements another class.
See attached screenshot.
Did this work before? No
Chrome version: 55.0.2883.75 Channel: stable
OS Version: 10.0
Flash Version:
,
Dec 19 2016
,
Dec 19 2016
This appears to be a CodeMirror bug. I filed an issue. https://github.com/codemirror/CodeMirror/issues/4450
,
Jan 9 2017
This bug got closed at CodeMirror because it seems to work on the latest version. Upgrading CodeMirror would most likely fix it in the developer tools too.
,
Oct 25 2017
Bumping this issue as it's been 10 months. This may just be a version bump to the latest codemirror. Note that the same breakage can be witnessed in Codemirror if the language mode is set to javascript, but it is ok in typescript. I wonder if the wrong language mode is being selected?
,
Oct 25 2017
I updated the CodeMirror bug here: https://github.com/codemirror/CodeMirror/issues/4450 String literals are valid even in Javascript, but indeed Chrome should set the mode to Typescript when displaying a TS file.
,
Nov 16 2017
I was going to give this bug a go today but when I installed Canary it looks like this bug resolved itself already. |
|||
►
Sign in to add a comment |
|||
Comment 1 by roger@versluis.ca
, Dec 19 2016