api-docs icon indicating copy to clipboard operation
api-docs copied to clipboard

set type in function parameters?

Open zhaocai opened this issue 7 years ago • 2 comments

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> {

zhaocai avatar Sep 01 '16 20:09 zhaocai

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

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

sharvil avatar Sep 02 '16 04:09 sharvil

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) {}

zhaocai avatar Sep 02 '16 07:09 zhaocai