Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Babel vs TSE: TrueKeyword and FalseKeyword #58

Closed
armano2 opened this issue Dec 21, 2018 · 6 comments
Closed

Babel vs TSE: TrueKeyword and FalseKeyword #58

armano2 opened this issue Dec 21, 2018 · 6 comments

Comments

@armano2
Copy link
Contributor

armano2 commented Dec 21, 2018

Currently we are parsing TrueKeyword and FalseKeyword as type='Literal' when in type, but babel parses them as BooleanLiteral,

i'm unsure what we should do with this...

@armano2 armano2 changed the title TrueKeyword and FalseKeyword Babel vs TSE: TrueKeyword and FalseKeyword Dec 21, 2018
@armano2
Copy link
Contributor Author

armano2 commented Dec 21, 2018

Babel expect when used as value:

const test = true;
{
  "type": "Program",
  "sourceType": "script",
  "body": [
    {
      "type": "VariableDeclaration",
      "declarations": [
        {
          "type": "VariableDeclarator",
          "id": {
            "type": "Identifier",
            "name": "test"
          },
          "init": {
            "type": "Literal",
            "value": true,
            "raw": "true"
          }
        }
      ],
      "kind": "const"
    }
  ]
}

when used as type:

type Foo = false
{
  "type": "Program",
  "sourceType": "script",
  "body": [
    {
      "type": "TSTypeAliasDeclaration",
      "id": {
        "type": "Identifier",
        "name": "Foo"
      },
      "typeAnnotation": {
        "type": "TSLiteralType",
        "literal": {
          "type": "BooleanLiteral",
          "value": false
        }
      }
    }
  ]
}

but we are always outputting it as Literal

@JamesHenry
Copy link
Owner

Hmm yeah, awkward one. IIRC BooleanLiteral is what babel does as standard and then the ESTree plugin converts it to Literal

@armano2
Copy link
Contributor Author

armano2 commented Dec 21, 2018

ok i will investigate that, and most likely report error there

@armano2
Copy link
Contributor Author

armano2 commented Dec 22, 2018

babel/babel#9228

@JamesHenry
Copy link
Owner

JamesHenry commented Dec 28, 2018

Thanks! I'll leave this issue open for now as a reminder

@JamesHenry
Copy link
Owner

We're not explicitly tracking any of the other babel issues on this repo so I'm going to close this for consistency with that

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants