question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider exporting `Fbt`, `FbtParam`, `FbtPlural`

See original GitHub issue

🚀 Feature Proposal

Export “empty” Fbt components

Motivation

Allow fbt to work better with TypeScript and friends. With this change types could be added to DefinentlyTyped and would make the setup a lot easier for TypeScript projects.

I think that it would make learning fbt easier in some sense too, using <fbt> and <fbt:param> throws people off when first seeing it.

Also if the babel-plugin was updated to I think we could remove the need for a auto-import option described in #194

Example

Please provide an example for how this feature would be used.

import {Fbt} from 'fbt'

function App() {
  return <Fbt desc="Greeting">Hello world</Fbt>
}

Pitch

I don’t see how this could be solved outside of fbt

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mrtnzlmlcommented, Apr 6, 2021

I’d like to support this proposal as well. Using JSXNamespacedName like fbt:param seems to be quite unconventional (even though valid) and it causes issues in various places like this one for example: https://github.com/yannickcr/eslint-plugin-react/pull/2961

Having something which is more “reacty” would be very nice.

1reaction
alexandernanbergcommented, Mar 17, 2021

Actually I was able to get typings to work with namespaced elements (<fbt:param> etc), so just creating @types/fbt would solve a lot. Might pick that up once I have some extra time.

Atm I just copied https://gist.github.com/retyui/c3bd35220fb5c95c322df866834f0913#file-index-d-ts locally. And you can even make it work in plain JS projects in VSCode with a jsconfig.json file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto import fbt in babel plugin · Issue #194 - GitHub
Feature Proposal Add support to auto import fbt in the babel plugin. ... Consider exporting Fbt , FbtParam , FbtPlural #202.
Read more >
Parameters and interpolation | FBT - Meta Open Source
Interpolation of dynamic text and other markup is accomplished in the FBT framework via ` or fbt.param`:
Read more >
How to add support Typescript for FBT an internationalization ...
import * as React from "react"; import fbt from "fbt"; const App = () => ( <fbt desc="welcome message"> Hi fbt & Typescript<fbt:param...
Read more >
TypeScript 4.2 Iteration Plan · Issue #41601 · microsoft/TypeScript ...
Consider exporting Fbt , FbtParam , FbtPlural facebook/fbt#202. Open. Sign up for free to join this conversation on GitHub. Already have an account?...
Read more >
Viewing online file analysis results for 'Facebook Hacker.exe'
... constructs such as fbt.plural() and the third positional `variations` argument to fbt.param() are currently disallowed":"";typeof e==="string"||Array.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found