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

No intellisense for required builtin node modules after installing @types/node #23780

Closed
mjbvz opened this issue Apr 30, 2018 · 12 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 30, 2018

From @shepelevstas on April 26, 2018 5:33

Version 1.22.2
Commit 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9
Date 2018-04-12T17:28:16.777Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture ia32

To reproduce:

CMD

md test
cd test
md src
npm init -y
npm i @types/node
tsc --init
code . --disable-extensions

//tsconfig.json

{
	// these are default
	"compilerOptions": {
		"target": "es5",
		"module": "commonjs",
		"strict": true,
		"esModuleInterop": true
	},
	// additional
	"files": [
		"./node_modules/@types/node/index.d.ts"
	],
	"include": [
		"src/**/*.ts"
	],
	"exclude": [
		"node_modules"
	]
}

//src/index.ts

const fs = require('fs')
var dirList = fs.| //<- **_NO INTELLISENSE_**

Or maybe I'm doing it wrong?

Copied from original issue: microsoft/vscode#48731

@mjbvz mjbvz self-assigned this Apr 30, 2018
@mjbvz mjbvz removed the typescript label Apr 30, 2018
@mjbvz mjbvz removed their assignment Apr 30, 2018
@mjbvz mjbvz changed the title No intellisense for .ts files No intellisense for required builtin node modules after installing @types/node Apr 30, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Apr 30, 2018

This works if you write:

import fs = require('fs')

I don't know if using plain require was ever supported

@ghost
Copy link

ghost commented Apr 30, 2018

See also #23711

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Apr 30, 2018
@WangPengJu
Copy link

WangPengJu commented May 1, 2018

@Andy-MS
a.ts

import fs = require("fs");
namespace G {
    export let a = 0;
}

b.ts

G.a // error 

I want use namespace as global(merger all file in one file). not single module. but if use "import fs = require('fs')" in "a.ts", "b.ts" can't use G. if use "const fs = require("fs")", it's work.

"const fs = require("fs")" no intellisense in vscode, webstorm have intellisense. it's confuse me.

@mhegazy
Copy link
Contributor

mhegazy commented May 1, 2018

A file can not be both a global script and a module. it is either one or the other.. import .. = require(..) only works for modules. if you are using namespaces, then you should do something like:

const fs: typeof import ("fs") = require("fs");

@mhegazy
Copy link
Contributor

mhegazy commented May 1, 2018

@weswigham do we have an issue for higher-order import types?

@weswigham
Copy link
Member

I don't think one's actually been opened yet, no.

@mhegazy
Copy link
Contributor

mhegazy commented May 1, 2018

We should then. we should collect such use cases.

@WangPengJu
Copy link

WangPengJu commented May 2, 2018

const fs: typeof import ("fs") = require("fs");

image
[ts] Cannot find name 'import'.
[ts] The left-hand side of an assignment expression must be a variable or a property access.

@mhegazy
i just want intellisense, use namespace. as global

@weswigham
Copy link
Member

@WangPengJu import types are only in the nightly right now, as we've yet to cut a release since adding them.

@WangPengJu
Copy link

WangPengJu commented May 2, 2018

ok. i can wait @weswigham
which one?
image

@WangPengJu
Copy link

2.9.0-dev.20180501
this version is work.
thx.
@weswigham

@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

5 participants