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

Cannot import JSON module as type #14913

Open
alex-kinokon opened this issue Jun 20, 2022 · 2 comments
Open

Cannot import JSON module as type #14913

alex-kinokon opened this issue Jun 20, 2022 · 2 comments
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@alex-kinokon
Copy link

Bug report

There doesn’t seem to be a way to import a JSON module purely as type.

Minimum reproduction:

// error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import assertion with the type of "json".
import type * as t from "./a.json";

Linter will also report a no-assert-type error. However, if you add the assertion as suggested by the linter, you get:

// error: TS2822 [ERROR]: Import assertions cannot be used with type-only imports or exports.
import type * as t from "./a.json" assert { type: "json" };
@nayeemrmn
Copy link
Collaborator

I guess it makes sense that TS doesn't like import assertions on type-only imports, they don't serve their purpose in that context. Accordingly deno_graph shouldn't enforce assertions (or lack thereof) on type-only imports.

@stale
Copy link

stale bot commented Sep 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 8, 2022
@kitsonk kitsonk added bug Something isn't working correctly cli related to cli/ dir labels Sep 8, 2022
@stale stale bot removed the stale label Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
Development

No branches or pull requests

3 participants