scala-js-ts-importer icon indicating copy to clipboard operation
scala-js-ts-importer copied to clipboard

correctly parse enum values

Open SrTobi opened this issue 6 years ago • 3 comments

this pr fixes #103

enum values can be expressions including

  • unary operators
  • binary operators
  • string and number literals
  • parenthesis
  • identifiers

See: https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#92-enum-members https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#419-binary-operators

Note: this implementation performs a flat parse that neither handles expression-tree-building nor operator precedences.

Note: This commit removes the minus from the NumericLit-token and parses it explicitly in TSDefParser.numberLiteral

SrTobi avatar Jun 16 '19 12:06 SrTobi

The CI fails because it uses typescript 2.6.2 for checking the typedefinitions in samples. Sometime between that and the newest version ([email protected]) the allowed syntax seems to have been broadened, as it works for me locally.

SrTobi avatar Jun 16 '19 13:06 SrTobi

TypeScript 2.6.2 was added just because it was latest when https://github.com/sjrd/scala-js-ts-importer/pull/56 was created. I think there is no reason to stay older TS, so it can be updated to 3.x.

exoego avatar Jun 16 '19 13:06 exoego

ah ok. I did that. thx

SrTobi avatar Jun 16 '19 13:06 SrTobi