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

Importing json on "module": "NodeNext" with assert { type: 'json' } #100

Open
Urigo opened this issue May 11, 2022 · 1 comment
Open

Importing json on "module": "NodeNext" with assert { type: 'json' } #100

Urigo opened this issue May 11, 2022 · 1 comment

Comments

@Urigo
Copy link

Urigo commented May 11, 2022

I want to import json file and use NodeNext module configurations:

For Node users using my lib I need to add assert { type: 'json' }
But when I use "module": "NodeNext", an import like that:

import isracardCardsTransactionsList from '../schemas/isracardCardsTransactionsList.json' assert { type: 'json' };

I get an error: error TS2836: Import assertions are not allowed on statements that transpile to commonjs 'require' calls.

When I go back to "module": "ESNext" it works.

What do you think would be the right configurations?

P.S. this is the repo: https://github.com/Urigo/israeli-bank-scrapers-modern-schemas

@Urigo Urigo changed the title Importing json on "module": "NodeNext" with assert { type: 'json' } Importing json on "module": "NodeNext" with assert { type: 'json' } May 11, 2022
@orta
Copy link
Member

orta commented May 14, 2022

Afraid I don't know, that feature shipped after I left the TypeScript team and I don't know the rules around it off the top of my head - I would have assumed that nodenext would allow it (assuming a modern target also)

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