sharvil / api-docs

An API documentation browser for Atom.
Other
57 stars 9 forks source link

set type in function parameters? #35

Open zhaocai opened 8 years ago

zhaocai commented 8 years ago

I think the syntax of the following lines in docset.js are wrong. Does JavaScript support type set in function parameters?

setEnabled_(enabled : boolean) {

queryAll() : Array<Object> {

sharvil commented 8 years ago

Babel enables optional type annotations (see 'use babel' directive at the top of the file).

http://babeljs.io/docs/plugins/transform-flow-strip-types/

zhaocai commented 8 years ago

How I notice this

Atom always crashes when I let it idle for a long while. Then I check the crash log; The last executed code points to setEnabled_(enabled : boolean) {. After I remove those type annotations, atom stops crashing.

It is a flow thing

Based on the link you give, it is a flow thing. Babel requires a plugin babel-plugin-transform-flow-strip-types to strip those types.

In

function foo(one: any, two: number, three?): string {}

Out

function foo(one, two, three) {}