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

npm: import does not resolve type correctly #24321

Closed
uga-rosa opened this issue Jun 24, 2024 · 2 comments
Closed

npm: import does not resolve type correctly #24321

uga-rosa opened this issue Jun 24, 2024 · 2 comments
Labels
needs triage types Issues related to TypeScript types

Comments

@uga-rosa
Copy link

Version: Deno 1.44.1

Summary

I want to use parse() of @babel/parser

https://babeljs.io/docs/babel-parser#babelparserparsecode-options

import { parse } from "npm:@babel/parser";

const ast = parse("const foo = {};");
console.log(ast);

image

Cause

Referring to the type definition of parse(). The reason is that this @babel/types cannot be resolved.

import * as _babel_types from '@babel/types';

// ...

declare function parse(
  input: string,
  options?: ParserOptions
): ParseResult<_babel_types.File>;

Workaround

You can use import map to replace @babel with npm:@babel so that you can trace it.

  • deno.json
{
  "imports": {
    "@babel": "npm:@babel"
  }
}

image

However, in my actual application, I use Worker, so this workaround doesn't work, because import map doesn't work.

@satyarohith satyarohith added needs triage types Issues related to TypeScript types labels Jun 24, 2024
@ryoppippi
Copy link

I tested with arktype, and got the same result

import { type } from "npm:arktype";

const user = type({
  name: "string",
});

Screenshot 2024-06-24 at 13 07 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage types Issues related to TypeScript types
Projects
None yet
Development

No branches or pull requests

4 participants