GithubHelp home page GithubHelp logo

Typescript support about fbt HOT 13 CLOSED

sibelius avatar sibelius commented on April 26, 2024 6
Typescript support

from fbt.

Comments (13)

retyui avatar retyui commented on April 26, 2024 5

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

UPD: use definition types:

yarn add @types/fbt

from fbt.

sibelius avatar sibelius commented on April 26, 2024 1

this could help https://github.com/sibelius/codemod-RN24-to-RN25/blob/master/transform.js#L22

from fbt.

sibelius avatar sibelius commented on April 26, 2024

collectFBT also throws when parsing typescript files with babel

Error: [BABEL] unknown: Configuration contains string/RegExp pattern, but no filename was passed to Babel
/entria-fullstack/node_modules/babel-plugin-fbt/bin/collectFBT.js:131
    throw new Error(`Failed in ${errCount} files`);
    ^

Error: Failed in 1 files
    at writeOutput (/entria-fullstack/node_modules/babel-plugin-fbt/bin/collectFBT.js:131:11)
    at ReadStream.<anonymous> (/entria-fullstack/node_modules/babel-plugin-fbt/bin/collectFBT.js:169:5)

from fbt.

sibelius avatar sibelius commented on April 26, 2024

after #51

I've got this error:

Error: Line 37 Column 11: `fbt` is not bound. Did you forget to require('fbt')?
/entria-fullstack/node_modules/babel-plugin-fbt/bin/collectFBT.js:131
    throw new Error(`Failed in ${errCount} files`);
    ^

Error: Failed in 1 files
    at writeOutput (/entria-fullstack/node_modules/babel-plugin-fbt/bin/collectFBT.js:131:11)
    at ReadStream.<anonymous> (/entria-fullstack/node_modules/babel-plugin-fbt/bin/collectFBT.js:169:5)
    at ReadStream.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1094:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

it could be related to #46

from fbt.

kayhadrin avatar kayhadrin commented on April 26, 2024
  1. Support for Typescript files is certainly on our radar but not scheduled yet.
  2. Re: the error about the absence of require('fbt'). That check was useful before when we had no proper way to check that fbt was a defined variable in the JS module scope. Now that we've got better Flow support, we can remove this. [EDIT] I've just rechecked and found that Flow is still not detecting <fbt> as a normal JSX+React component, which is interpreted as a special FbtElement type. So for now, we'll need to keep that variable definition check.

from fbt.

baluubas avatar baluubas commented on April 26, 2024

@kayhadrin Do you have any pointers where that check is made? Or some way to work around it in the mean time? I wouldn't mind keeping a fork going until things are ready for typescript support.

from fbt.

sibelius avatar sibelius commented on April 26, 2024

@baluubas you can use my 2 pull requests

#50
#51

from fbt.

kayhadrin avatar kayhadrin commented on April 26, 2024

@baluubas I believe @sibelius answered your question.

from fbt.

kayhadrin avatar kayhadrin commented on April 26, 2024

@sibelius Re: #49 (comment)

Could you provide an example of how you're importing fbt in your JS module?

I assume it's something like this:

import fbt from 'fbt';
// or
import {fbt} from 'fbt';

from fbt.

sibelius avatar sibelius commented on April 26, 2024

Iā€™m using export default

Checking the code, I could use named or export default

For me, anyone of them could work

from fbt.

kayhadrin avatar kayhadrin commented on April 26, 2024

I've applied the your two PRs locally (#50 and #51),
converted the demo-app/src/example/Example.react.js file to tsx,
ran yarn manifest and yarn collect-fbts and it worked successfully.

If that's still an issue on your side, you may want to submit the minimum repro code in a Codepen.

from fbt.

AndrewCraswell avatar AndrewCraswell commented on April 26, 2024

It seems the pull requests were merged, can this issue be closed or is Typescript still not fully supported?

from fbt.

jrwats avatar jrwats commented on April 26, 2024

I'll close for now, and if any further issues around Typescript arise, we can investigate them as a separate issue.

from fbt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.