Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

Option to generate .ts instead of .tsx #453

Closed

Description

@chrischen

Is there an option to generate .ts instead of .tsx? I'm using Reason in a Typescript-node server side application and don't need JSX support.

Activity

  1. cristianoc commented on Aug 20, 2020

    @cristianoc
    Collaborator

    There's no option to generate .ts files at the moment. Is there some problem arising from having .tsx files? In theory they should be just picked up like .ts files are.

  2. chrischen commented on Aug 20, 2020

    @chrischen
    Author

    It’s trivial to get it to work. It’s just some tooling needs to be updated to work with tsx, but I figure if it’s easy enough to just change the extension of the generated files it could encourage more non-react usage.

  3. adnelson commented on Feb 5, 2021

    @adnelson

    Here's one reason why that would be helpful:

    6:28:39 PM - File change detected. Starting incremental compilation...
    [TS] 
    [TS] src/repositories/AppRepository.ts(25,8): error TS6142: Module '../FirebaseSchema.gen' was resolved to '/Users/allennelso
    n/workspace/draftbit/draftbit/server/src/FirebaseSchema.gen.tsx', but '--jsx' is not set.
    [TS] src/repositories/ScreenRepository.ts(23,36): error TS6142: Module '../FirebaseSchema.gen' was resolved to '/Users/allenn
    elson/workspace/draftbit/draftbit/server/src/FirebaseSchema.gen.tsx', but '--jsx' is not set.
    [TS] src/repositories/ScreenRepository.ts(63,8): error TS7031: Binding element 'name' implicitly has an 'any' type.
    [TS] src/repositories/ScreenRepository.ts(69,42): error TS7006: Parameter 'col' implicitly has an 'any' type.
    [TS] 
    [TS] 6:28:44 PM - Found 4 errors. Watching for file changes.
    

    .tsx only seems like right extension if there's JSX in the output; perhaps it's possible to detect?

  4. davesnx commented on Feb 8, 2021

    @davesnx

    As a workaround, we endup adding a "js-post-build" in bsconfig and run a script that copies the files without the .tsx extension:

    #!/usr/bin/env sh
    
    set -e;
    
    # We specify ../../src since we are inside lib/bs
    # where bsb have ninja and runs "js-post-build" step
    # This script isn't meant to run standalone.
    genFiles=$(find ../../src -iregex '.*\.gen\.tsx$');
    
    for pth in $genFiles; do
      cp "$pth" "$(sed 's/.gen.tsx/.gen.ts/' <<< "$pth")";
    done
    
  5. cristianoc commented on Feb 9, 2021

    @cristianoc
    Collaborator

    You can try release 3.43, and add "generatedFileExtension": ".gen.ts" under "gentypeconfig".
    This option stays experimental, try only for specific use cases.

  6. adnelson commented on Feb 10, 2021

    @adnelson

    @cristianoc just upgraded and it seems like it works perfectly, thanks! 😄

  7. cristianoc commented on Feb 12, 2021

    @cristianoc
    Collaborator

    Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions