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

Not able to import json files in TSX files #15835

Closed
synckarthik opened this issue Jun 7, 2019 · 2 comments
Closed

Not able to import json files in TSX files #15835

synckarthik opened this issue Jun 7, 2019 · 2 comments

Comments

@synckarthik
Copy link

I have tried to import the json file in my react application(App.tsx)

[App.tsx

import * as currencies from './currencies.json';](url)

My Json file will look like below structure:

{
"main": {
"numbers": {
"currencies": {
}
}
}
}

While running the application, it throws the below error

(1,1): unused expression, expected an assignment or function call

After further analysis, i have added the typings.d.ts file within src folder

declare module "*.json" {
const value: any;
export default value;
}

Please suggest your solution to resolve this issue

@synckarthik
Copy link
Author

Is any update on this issue?

@threepointone
Copy link
Contributor

threepointone commented Jun 11, 2019

Did you mean to post this in https://github.com/facebook/create-react-app/issues? Doesn't look like anything to do with React.

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

2 participants