Skip to content

Importing types in JS files stopped working. #27302

Closed

Description

@zavr-1

Issue Type: Bug

There

VS Code version: Code - Insiders 1.28.0-insider (2558a72, 2018-09-21T05:12:46.853Z)
OS version: Darwin x64 15.6.0

System Info
Item Value
CPUs Intel(R) Core(TM)2 Duo CPU P7350 @ 2.00GHz (2 x 2000)
GPU Status 2d_canvas: unavailable_software
checker_imaging: disabled_off
flash_3d: unavailable_software
flash_stage3d: unavailable_software
flash_stage3d_baseline: unavailable_software
gpu_compositing: unavailable_software
multiple_raster_threads: disabled_off
native_gpu_memory_buffers: unavailable_software
rasterization: unavailable_software
video_decode: unavailable_software
video_encode: unavailable_software
webgl: unavailable_off
webgl2: unavailable_off
Load (avg) 4, 11, 10
Memory (System) 8.00GB (0.12GB free)
Process Argv /Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron -psn_0_2023918
Screen Reader no
VM 0%
Extensions (5)
Extension Author (truncated) Version
vscode-eslint dba 1.6.0
svg joc 0.1.4
autoimport ste 1.5.3
code-spell-checker str 1.6.10
vscode-wakatime Wak 1.2.3

Since last week, importing of external types has stopped working.

screen shot 2018-09-24 at 12 47 10

screen shot 2018-09-24 at 12 52 03

screen shot 2018-09-24 at 13 01 20

It works in non-insiders. This has definitely worked in insiders fine last week.

screen shot 2018-09-24 at 12 48 03

screen shot 2018-09-24 at 13 02 20

And no I don't want to convert to TypeScript.

Activity

  1. sandersn commented on Sep 24, 2018

    @sandersn
    Member

    My initial attempt at a repro failed -- everything succeeded. I'm going to try a clean npm init etc since I was testing in a directory with an explicit tsconfig.json and that already had @types/koa installed. This might be a failure in automatic type acquisition, since @types/koa has app.middleware: compose.Middleware<koa.Context>[] not any[].

    Do you have a tsconfig.json or jsconfig.json? Or have you explicitly done npm install @types/koa?

  2. sandersn commented on Sep 24, 2018

    @sandersn
    Member

    From a fresh start, I can't repro your errors either; I think VS Code was either automatically installing @types/koa or perhaps it was in your package.json, because the types you have from your Working screenshot references types that are only in the d.ts, not in the actual package.

    Specifically, koa.Middleware is a type defined only in the .d.ts.

    ✔ bug27302  [master|✚ 3…6]$ node
    > const koa = require('koa')
    undefined
    > koa.Middleware
    undefined
    

    Andy (Andrewkraft) (@Andy-MS) Does this look like a failure in Automatic Type Acquisition?

    zavr-1 Since this appears to be a problem with either the language service or VS Code, can you set the language service to dump its logs somewhere and send them to me or Andy (Andrewkraft) (@Andy-MS)? You have to set this environment variable: SET TSS_LOG=-level verbose -file C:\temp\logs\tsserver.log. We'd like to see the log from setting up a new project that uses koa, then pasting in the simple repro you gave above.

    My Microsoft mail is nathansa.

  3. zavr-1 commented on Sep 24, 2018

    @zavr-1
    Author

    Hi no I don't have tsconfig or jsconfig I was just using running project as I always do and writing type {import('koa').Middleware} worked on Friday and then I came back after the weekend it stopped after a restart, so I reckoned it must be some commit that got merged... also it's not just middleware it's everything.
    Here's the log tsserver.log

    test

    And this is the repo https://github.com/idiocc/test

  4. zavr-1 commented on Sep 24, 2018

    @zavr-1
    Author
  5. zavr-1 commented on Sep 25, 2018

    @zavr-1
    Author

    And so it works today... Sorry don't know what's happened. The only thing different from last night was that there was a pending update (restart to update) to 2018-09-24T11:57:32.166Z but it started working before I restarted. I guess it can be closed now...

  6. zavr-1 commented on Sep 25, 2018

    @zavr-1
    Author

    I Think it's the same issue. To reproduce:

    1. git clone git@github.com:idiocc/test.git
    2. cd test; git checkout insider
    3. code-insiders .
    4. open src/index.js
    5. click through on idio -- the koa-router will have an error. (I have an error because it's not discovered). Although there seems to be a type, it's not from definitions and is incomplete. If I don't specify the return type explicitly, I won't have neither router nor middleware as shown in the referenced issue. I really don't think I should have to write types for my packages when I just return objects created with constructors.

    screen shot 2018-09-25 at 16 08 46

    If I add it as package dependency, it works fine.

  7. JacksonKearl commented on Sep 26, 2018

    @JacksonKearl

    Getting this as well, simple repro:

    VSCode 1.27.2
    TypeScript 3.0.3

    package.json:

    {
        "dependencies": {
            "express": "4.16.3"
        }
    }
    

    npm install

    main.ts:

    import * as express from "express" // Error: Could not find a declaration file for module 'express'. '/Users/jacksonkearl/Desktop/test/node_modules/express/index.js' implicitly has an 'any' type.
      Try `npm install @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`
    
    let a = express()
    
    

    tsconfig.json:

    {
        "compilerOptions": {
            "strict": true
        },
        // No change with this enabled:
        // "typeAcquisition": {
        //     "enable": true
        // }
    }
    
  8. peteroid commented on Oct 10, 2018

    @peteroid

    I was experiencing this issue while using the vscode with default Typescript version 3.1.0. Finally got the intellisense back after downgrading the ts to 3.0.3

  9. ghost closed this as completedin #28236on Oct 30, 2018
  10. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions