Skip to content

npm default export is incorrectly typed for clsx #19096

@pting-me

Description

@pting-me

Describe the bug

npm:* default exports are incorrectly typed. Packages that are exported as default are assumed to have a default property. The plugin will claim a type error when there are no actual runtime errors. Furthermore, trying to appease the plugin error by using the default property will actually result in runtime errors.

To Reproduce

  1. Create a file script.ts
import clsx from 'npm:clsx';

console.log(clsx("hello", "goodbye"));
  1. Cache dependencies, notice the following error:
This expression is not callable.
  Type 'typeof import("file:///Users/pting/Library/Caches/deno/npm/registry.npmjs.org/clsx/1.2.1/clsx")' has no call signatures.deno-ts(2349)
  1. Try running deno run script.ts, notice there are no errors at runtime

  2. Try appeasing the compiler:

console.log(clsx.default("hello", "goodbye"));
  1. Notice runtime error.

Expected behavior

Expected plugin parsing behavior to match runtime behavior.

Screenshots

Screen Shot 2023-04-27 at 9 54 50 PM

Versions

vscode: 1.77.3 deno: 1.33.0 extension: 3.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidwhat appeared to be an issue with Deno wasn'tnode compat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions