Closed
Description
TypeScript Version: typescript v2.9.0-dev.20180519
(Also with v2.8.3)
Search Terms:
"as keyword" newline
"as keyword" whitespace
Code
Fails:
const x = 2
as number;
console.log(x);
Works:
const x = 2 as
number;
console.log(x);
Expected behavior:
Successful compilation (and output "2
"...).
Actual behavior:
tsnode says:
...(2,4): ';' expected. (1005)
Playground puts wiggly red lines on everything, starting on first as
.
Playground Link: https://www.typescriptlang.org/play/#src=const%20x%20%3D%202%0D%0A%20%20as%20number%3B%0D%0Aconsole.log(x)%3B%0D%0A
Related Issues:
Couldn't find something similar (see search terms above). It looks related to the general weirdness associated with newlines in JavaScript. The playground seems to support this, it shows this translation:
x = 2;
as;
number;
console.log(x);