Skip to content

Resolved import has implicit 'any' type without warnings #1320

@jc776

Description

@jc776

Describe the bug

To Reproduce

deno.jsonc:

{
  "nodeModulesDir": "none",
  "imports": {
    "react": "npm:react@^19.1.0",
    //"@types/react": "npm:@types/react@^19.1.8"
  }
}

test.ts:

import { useState, aaaaa } from 'react'
import { bbbbb } from 'ccccc'

const x = useState
const y = aaaaa
const z = bbbbb

console.log(x)
console.log(y)
console.log(z)

I set up these files with an npm import, without node_modules dir, but was missing the @types import.

  1. Running test.ts correctly shows error for the missing ccccc. This is correctly highlighted red in VSCode (first screenshot).
deno run --allow-env test.ts
error: Relative import path "ccccc" not prefixed with / or ./ or ../ and not in import map from "file:///[omitted]/test.ts"
    at file:///[omitted]/test.ts:2:23

# no error?
deno check test.ts
Check file:///[omitted]/test.ts
  1. If I comment out ccccc and z, deno correctly shows an error for the missing import. VSCode does resolve react but does not show the same as an error or a warning. (second screenshot)
    VSCode shows the type of x and y as any. (third screenshot)
deno run --allow-env test.ts
error: Uncaught SyntaxError: The requested module 'react' does not provide an export named 'aaaaa'
import { useState, aaaaa } from 'react'
                   ^

# no error?
deno check test.ts          
Check file:///[omitted]/test.ts
  1. If I comment out aaaaa and y, VSCode shows the type of x as any. deno allows this to run, I thought it was set by default to strict and noImplicitAny? What settings do I need to have "no implicit any" enforced on these imports?
deno run --allow-env test.ts
[Function (anonymous)]

# no output?
deno check test.ts
  1. If I add @types/react, VSCode correctly shows a red error for aaaaa and shows the types for useState and x. (fifth/sixth screenshots)

Expected behavior

When missing @types/react, VSCode should show a warning or error for the implicit any types imported from react. Currently no error. (third screenshot)

Screenshots

In both cases, the missing ccccc correctly shows error:
Image

Without @types/react, react resolves but no warning or error on aaaaa. x and y have type any with no warning or error. useState and aaaaa just show import aaaaa.
Image
Image
Image

With @types/react, correctly shows error for aaaaa and resolves types for x and useState:
Image
Image

Versions

vscode: 1.102.2 (Universal)
deno: 2.4.2 (stable, release, aarch64-apple-darwin)
extension: 3.45.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions