mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #10708 from atom/flow-implies-babel
Flow implies Babel
This commit is contained in:
@@ -4,6 +4,7 @@ BABEL_PREFIXES = [
|
||||
"'use babel'"
|
||||
'"use babel"'
|
||||
'/** @babel */'
|
||||
'/* @flow */'
|
||||
]
|
||||
|
||||
PREFIX_LENGTH = Math.max(BABEL_PREFIXES.map((prefix) -> prefix.length)...)
|
||||
|
||||
@@ -36,6 +36,11 @@ describe "Babel transpiler support", ->
|
||||
transpiled = require('./fixtures/babel/babel-double-quotes.js')
|
||||
expect(transpiled(3)).toBe 4
|
||||
|
||||
describe 'when a .js file starts with /* @flow */', ->
|
||||
it "transpiles it using babel", ->
|
||||
transpiled = require('./fixtures/babel/flow-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", ->
|
||||
expect(-> require('./fixtures/babel/invalid.js')).toThrow()
|
||||
|
||||
4
spec/fixtures/babel/flow-comment.js
vendored
Normal file
4
spec/fixtures/babel/flow-comment.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/* @flow */
|
||||
|
||||
const f: Function = v => v + 1
|
||||
module.exports = f
|
||||
@@ -10,7 +10,8 @@ var babelVersionDirectory = null
|
||||
var PREFIXES = [
|
||||
'/** @babel */',
|
||||
'"use babel"',
|
||||
'\'use babel\''
|
||||
'\'use babel\'',
|
||||
'/* @flow */'
|
||||
]
|
||||
|
||||
var PREFIX_LENGTH = Math.max.apply(Math, PREFIXES.map(function (prefix) {
|
||||
|
||||
Reference in New Issue
Block a user