diff --git a/src/workers/parser/getSymbols.js b/src/workers/parser/getSymbols.js index d235af67b5..6e97bacf88 100644 --- a/src/workers/parser/getSymbols.js +++ b/src/workers/parser/getSymbols.js @@ -165,7 +165,12 @@ function extractSymbols(source: Source) { } if (t.isIdentifier(path)) { - const { start, end } = path.node.loc; + let { start, end } = path.node.loc; + + if (path.node.typeAnnotation) { + const column = path.node.typeAnnotation.loc.start.column; + end = { ...end, column }; + } identifiers.push({ name: path.node.name, diff --git a/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap b/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap index 55bf797222..cc05021b60 100644 --- a/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap +++ b/src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap @@ -639,6 +639,39 @@ identifiers: classes: +imports: +" +`; + +exports[`Parser.getSymbols flow 1`] = ` +"functions: +[(2, 2), (4, 3)] renderHello(name) App + +variables: +[(2, 14), (2, 26)] name + +callExpressions: + + +memberExpressions: + + +objectProperties: + + +comments: + + +identifiers: +[(1, 6), (1, 9)] App App +[(2, 2), (2, 13)] renderHello renderHello +[(2, 14), (2, 18)] name name +[(3, 20), (3, 24)] name name +[(1, 18), (1, 27)] Component Component + +classes: +[(1, 0), (5, 1)] App + imports: " `; diff --git a/src/workers/parser/tests/fixtures/flow.js b/src/workers/parser/tests/fixtures/flow.js new file mode 100644 index 0000000000..0294f197c5 --- /dev/null +++ b/src/workers/parser/tests/fixtures/flow.js @@ -0,0 +1,5 @@ +class App extends Component { + renderHello(name: string) { + return `howdy ${name}`; + } +} diff --git a/src/workers/parser/tests/getSymbols.spec.js b/src/workers/parser/tests/getSymbols.spec.js index b55ac4bbe4..58850c64b9 100644 --- a/src/workers/parser/tests/getSymbols.spec.js +++ b/src/workers/parser/tests/getSymbols.spec.js @@ -24,6 +24,7 @@ cases( type: "html" }, { name: "component", file: "component" }, - { name: "react component", file: "frameworks/component" } + { name: "react component", file: "frameworks/component" }, + { name: "flow", file: "flow" } ] );