You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some npm dependencies like socket.io or cheerio that provide type info for TS via the package.json types field.
This works just fine in a TS file such as server.ts:
importsocketIO= require('socket.io')socketIO.blah// correctly warns about property not existingsocketIO.Socket// correctly knows this exists
In javascript files however I get en error on the require line, ex in server.js:
// @ts-checkconstsocketIO=require('socket.io')// "Cannot find module 'socket.io' or its corresponding type declarations"
I did try and add a reference path comment/hint but that didn't work in server.js:
// @ts-check/// <reference path='./node_modules/socket.io/dist/index.d.ts' />constsocketIO=require('socket.io')// "Cannot find module 'socket.io' or its corresponding type declarations"
However, type info comes through just fine for anything I've had to use DefinitelyTyped for. So for example if I have express as a dependency and @types/express as a devDependency then this works in server.js:
// @ts-checkconstexpress=require('express')express.blah// correctly warns about property not existingexpress.static// correctly knows this exists
Seems like something is missing here when it comes to reading the types field off of package.json for dependencies. Is this just broken/missing functionality for javascript files or am I just missing some kind configuration or something?
The text was updated successfully, but these errors were encountered:
I have some npm dependencies like socket.io or cheerio that provide type info for TS via the package.json types field.
This works just fine in a TS file such as server.ts:
In javascript files however I get en error on the require line, ex in server.js:
I did try and add a reference path comment/hint but that didn't work in server.js:
However, type info comes through just fine for anything I've had to use DefinitelyTyped for. So for example if I have
express
as a dependency and@types/express
as a devDependency then this works in server.js:Seems like something is missing here when it comes to reading the types field off of package.json for dependencies. Is this just broken/missing functionality for javascript files or am I just missing some kind configuration or something?
The text was updated successfully, but these errors were encountered: