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

Intellisense autocomplete does not work well for JS #31233

Closed
akontsevich opened this issue Jul 21, 2017 · 10 comments
Closed

Intellisense autocomplete does not work well for JS #31233

akontsevich opened this issue Jul 21, 2017 · 10 comments
Assignees
Labels
javascript JavaScript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@akontsevich
Copy link

akontsevich commented Jul 21, 2017

Steps to Reproduce:

  1. Created simple bot app with node js (code mentioned below). Auto-complete works fine in line 22 for session parameter.
  2. However does not work in line 29 for session parameter (in ReceiveMessage() function) even with JSDoc definitions.
var restify = require('restify');
var builder = require('botbuilder');

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url); 
});

// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});

// Listen for messages from users 
server.post('/api/messages', connector.listen());

// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var dialog = require("./rootdialog")
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("You said: %s", session.message.text);
});

/**
 * @param {Session} {session}
 */
function ReceiveMessage(/*Session*/session) {
    session.send("You said: %s", session.message.text);    
}

VS Code for Node.js Development Quickstart Pack extension installed, does not work without it as well.

Reproduces without extensions: Yes

@vscodebot vscodebot bot added the javascript JavaScript support issues label Jul 21, 2017
@mjbvz mjbvz added the info-needed Issue requires more information from poster label Jul 21, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Jul 21, 2017

Where is the type Session defined? Is it coming from one of the imported libraries?

@akontsevich
Copy link
Author

akontsevich commented Jul 21, 2017

Yes it comes with botbuilder:
npm install --save botbuilder
npm install --save restify

Defined in file: node_modules/botbuilder/lib/botbuilder.d.ts

@mjbvz
Copy link
Collaborator

mjbvz commented Jul 23, 2017

Try using the module name when referencing types:

/**
 * @param {builder.Session} session
 */
function ReceiveMessage(/*Session*/session) {
    session.send("You said: %s", session.message.text);    
}

Also try enabling JavaScript type checking to track down undefined type references

@akontsevich
Copy link
Author

Both does not work: [js] can not find name Session or [js] can not find name builder.

@mjbvz mjbvz added upstream Issue identified as 'upstream' component related (exists outside of VS Code) and removed info-needed Issue requires more information from poster labels Jul 25, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Jul 25, 2017

Looks like microsoft/TypeScript#11825

These patterns should work:

import * as builder from 'botbuilder';

/**
 * @param {builder.Session} session
 */
function ReceiveMessage(session) {
    session.send("You said: %s", session.message.text);    
}

or

const {Session} = require('botbuilder');

/**
 * @param {Session} session
 */
function ReceiveMessage(session) {
    session.send("You said: %s", session.message.text);    
}

Closing as upstream

@mjbvz mjbvz closed this as completed Jul 25, 2017
@akontsevich
Copy link
Author

Thanks! Works.

@akontsevich
Copy link
Author

const { IConversationUpdate } = require('botbuilder'); does not work for IConversationUpdate object for some reason.

And if I make
import * as builder from 'botbuilder';
then get error in app.js: Unexpected token import for
var dialog = require("./rootdialog")
where all of above exists. Any other solution?

@akontsevich
Copy link
Author

akontsevich commented Oct 8, 2017

Guys, please reopen this bug as the issue was not solved! Things works fine in IntelliJ IDEA and fails in VS Code.

@mjbvz
Copy link
Collaborator

mjbvz commented Oct 13, 2017

@akontsevich microsoft/TypeScript#11825 is tracking the issue with const { IConversationUpdate } = require('botbuilder');

The unexpected token one seems unrelated. Does this reproduce with all extensions disabled?

@akontsevich
Copy link
Author

Yes, reproducible.
/** @param {Session} session */
Still does not work. Works fine in IntelliJ - will stay on it for now.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants