facebook/fbt

Syntax errors when using fbt-collect on Typescript files

nashspence opened this issue ยท 4 comments

๐Ÿ› Bug Report

When running fbt-collect on a Typescript file, it errors out with syntax errors due to Babel not recognizing Typescript-specific syntax. In order to have have Babel understand this syntax, you need to run Babel with the Typescript preset. However, presets are not currently a supported option on the cli. I will be submitting a pull request that adds this as an ability, which allows me to successfully use fbt-collect on a .tsx file.

To Reproduce

  • Run fbt-collect on a .tsx file that has Typescript-specific syntax

Expected behavior

  • fbt-collect collects the strings without erroring, just like it would on a .jsx file

Link to repo (highly encouraged) or paste

N/A

envinfo

System:
OS: macOS 10.15.4
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Memory: 1.30 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 13.13.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm

Here is an article about Typescript + fbt where I describe problems that i faced and how to fix them

@retyui no worries man. Iโ€™ve also seen this article which has more info - https://medium.com/@frenchyooy/configuring-fbt-api-with-typescript-and-react-create-app-492ee72f44bb. We have fbt working nowadays in our typescript project. My only thing is that Iโ€™m hoping that the team will accept the PR I submitted for setting a Babel preset for the collect CLI to use. The import problem you mention may be a known issue #115 btw, tho it looks like it might be a little stale as it is tagged Needs Repro. I can confirm that we reproduced an import problem with our set up. Needed to put โ€œfbt;โ€ somewhere in the file to get it to work. This particular issue here tho is just about getting the fbt-collect CLI to be easily usable with typescript as I think is a goal of the project.

@nashspence we're actively working on landing your PR as I write this. Sorry for the delay, a few of us have been AFK due to COVID, etc!

@jrwats no worries no hurry. Thanks for the update and the tool. Iโ€™ve been away a bit myself too.