Skip to content

Unexpected token (2:9) #11

@ghost

Description

Hello,

I used to use contracts in Racket of all languages, so glad to see something similar exists for JS!

Anyway, every time I try to compile anything with the contracts plugin, I get Unexpected token (2:9). It doesn't matter what is at position 2:9, even comments will trigger the same error.

.babelrc

{
  "plugins": [
    ["contracts", {
      "names": {
        "assert": "assert",
        "precondition": "pre",
        "postcondition": "post",
        "invariant": "invariant",
        "return": "it",
        "old": "old"
      }
    }]
  ]
}

test.js

const add1 = n => {
	pre: typeof n === 'number';
	return n + 1
}

babel --version

6.26.0 (babel-core 6.26.3)

Do I need babel 7 for this? 6.26.3 is the latest version in npm.

https://www.npmjs.com/package/babel-core

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions