Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with Typescript? #35

Closed
slorber opened this issue Mar 29, 2019 · 2 comments
Closed

Does not work with Typescript? #35

slorber opened this issue Mar 29, 2019 · 2 comments

Comments

@slorber
Copy link

slorber commented Mar 29, 2019

Hi,

I understand this can be quite challenging to support but that would be useful to be able to use this on typescript projects. In my case it's a Gatsby site with Typescript plugin, so there's not even a .babelrc config. Not sure how this can be done, just reporting that this script is failing on such a file:


import React, { ReactNode } from 'react';
import classnames from 'classnames';

const CartItem = ({
  label,
  price,
  children,
}: {
  label: string;
  price: number;
  children: ReactNode;
}) => (
  <article className="cart-item">
    <p className="cart-item__title">
      <b>{label}</b>
      <span className="cart-item__price">{price}€</span>
    </p>
    <p className="cart-item__detail">{children}</p>
  </article>
);

export default CartItem;

@Evanion
Copy link

Evanion commented Aug 22, 2019

extract-messages -l=en,sv -o src/Locales -d en --flat false 'src/**/!(*.test).ts'

I just ran this on my React-native project that uses TypeScript, and it extracted the messages just fine. I'm confused what your issue is. What is the error you are getting?
The code you included doesn't contain any react-intl code, The label is passed in as a prop from the parent component.

@akameco
Copy link
Owner

akameco commented Aug 25, 2019

babel is required.
https://babeljs.io/docs/en/babel-preset-typescript

yarn add --dev @babel/core @babel/cli @babel/preset-typescript

.babelrc

{
  "presets": ["@babel/preset-typescript"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants