Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casting in an object with 'as' fails with parsing error unexpected token #10365

devlinb opened this issue Aug 23, 2019 · 2 comments


Copy link

commented Aug 23, 2019

Bug Report

Current Behavior
Casting in a plain object using "as" when assigning a field fails.

Input Code

  • REPL or Repo link if applicable:
const inputStyle = {
 textStyle: 'center' as const, 

Babel repl

Typescript repl

Expected behavior/code
Behavior of TS plugin does same thing as TSC

Babel Configuration (.babelrc, package.json, cli command)


module.exports = function(api) {
  return {
    presets: [["module:metro-react-native-babel-preset"], ['react-app'],  ["@babel/preset-typescript"]],
    ignore: [ "node_modules/art/core/color.js" ],
    plugins: [
      ["module-resolver", {
        "alias": {
          "^react-native$": "react-native-web"

Relevant parts of package.json

"devDependencies": {
  "@babel/core": "7.1.0",
  "@babel/plugin-transform-typescript": "^7.5.5",
  "@babel/preset-typescript": "^7.3.3",
  "babel-eslint": "9.0.0",
  "babel-jest": "23.6.0",
  "babel-loader": "8.0.4",
  "babel-plugin-module-resolver": "^3.1.1",
  "babel-plugin-named-asset-import": "^0.2.3",
  "babel-preset-react-app": "^6.1.0",


  • Babel version(s): 7.1.0
  • Node/npm version: node v10.15.3 NPM 6.4.1
  • OS: [Win10]
  • Monorepo: No
  • How you are using Babel: Loader

This comment has been minimized.

Copy link

commented Aug 23, 2019

Hey @devlinb! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.