Closed vivekgalatage closed 6 years ago
That’s the correct AST — see this example with just a number.
This also applies to the decorators where the argument 3.14 is treated as Literal
function $scope(scope: any[], chart: string, pi: number) {
return (target: Function) => {}
}
@$scope(['hello'], 'bar', 3.14)
export class ExportedClass {
}
This gist [1] specifies the type as NumericLiteral
@vivekgalatage The TypeScript parser doesn’t follow the ESTree spec, which specified that all literales are of the Literal
type.
@j-f1 sure, thanks for the clarification. So in that case, how does the developer would differentiate between the numerical values vs the literal values. Or are we not supposed to use the non literal values at these places?
String literals have a string value
, and numeric literals have a numeric value
.
Fantastic!!! And my apologies for missing this info. Thank you!
What version of TypeScript are you using? 2.8.1
What version of
typescript-eslint-parser
are you using? 15.0.0What code were you trying to parse?
What did you expect to happen? The enum initializer type is number whereas the generated JSON states it to be a string literal. The typescript compiler treats this as a number only.
What happened?![image](https://user-images.githubusercontent.com/1282684/39178894-83dedea8-47d0-11e8-83dd-d6f5ec4215f0.png)