allow the use of double slash flow comments

This commit is contained in:
saadq
2018-03-21 18:07:16 -04:00
parent bed867f35b
commit fc45af02ae
3 changed files with 11 additions and 1 deletions

View File

@@ -42,6 +42,11 @@ describe "Babel transpiler support", ->
transpiled = require('./fixtures/babel/flow-comment.js')
expect(transpiled(3)).toBe 4
describe 'when a .js file starts with // @flow', ->
it "transpiles it using babel", ->
transpiled = require('./fixtures/babel/flow-slash-comment.js')
expect(transpiled(3)).toBe 4
describe "when a .js file does not start with 'use babel';", ->
it "does not transpile it using babel", ->
spyOn(console, 'error')

View File

@@ -0,0 +1,4 @@
// @flow
const f: Function = v => v + 1
module.exports = f

View File

@@ -11,7 +11,8 @@ var PREFIXES = [
'/** @babel */',
'"use babel"',
'\'use babel\'',
'/* @flow */'
'/* @flow */',
'// @flow'
]
var PREFIX_LENGTH = Math.max.apply(Math, PREFIXES.map(function (prefix) {