angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

Node, Node Modules Intellisense in Visual Studio Code #2145

Open rohita77 opened 8 years ago

rohita77 commented 8 years ago

Was wondering if anybody has got intellisense working in Visual studio code using the generated project. VSCode requires

https://code.visualstudio.com/docs/runtimes/nodejs

I can see node.d.ts being referenced from github in typings(ts).json but not sure how this is used in the project. Additionally, other definition files will be required the many npm modules being used. Do we install these manually

Awk34 commented 8 years ago

I believe VS Code requires a tsconfig.json explicitly, whereas we create two ts config files: one for the client code, and one for the client test code. You might need to create your own tsconfig.json. The typings.json manifest is used by typings to download type definitions.

Koslun commented 8 years ago

Not sure that VS Code supports a glob pattern in tsconfig.json yet either. Meaning you potentially can't just copy tsconfig.client.json. You can use a gulp task to automatically generate this file and maybe just run it in parallell to all the gulp serve tasks or run it manually whenever you want to update the definition.

function injectTsConfig(filesGlob, tsconfigPath) {
  const src = gulp.src(filesGlob, { read: false })
        .pipe(plugins.sort());

  return gulp.src(tsconfigPath)
        .pipe(plugins.inject(src, {
          starttag: '"files": [',
          endtag: ']',
          transform: (filepath, file, i, length) =>
            `"${filepath.substr(1)}"${i + 1 < length ? ',' : ''}`
          ,
        }))
        .pipe(gulp.dest('./'));
}

gulp.task('inject:tsconfig', () =>
  injectTsConfig([
    `${clientPath}/**/*.ts`,
    'typings/**/*.d.ts',
  ],
    './tsconfig.json')
);
rohita77 commented 8 years ago

Thanks.. I don't see the typings.json in version 3.10.3. Is this something that is only put in version 4?

Awk34 commented 8 years ago

@rohita77 we don't have a 3.10.3. The latest 3.x.x version we have is 3.7.6.

rohita77 commented 8 years ago

I guess the files are not in my version. I can see it Github in version 4 though. What is the purpose of this file? How are the typings downloaded?. Do I need to run "typings install" or is this taken care by some gulp task? Also, I cannot see any entries for server side modules like Mongoose /express. On the client side I don't see typings for angular-ui-router or angular-ui-bootstrap.

Awk34 commented 8 years ago

The generated package.json has a postinstall script that runs typings install, so it should get run automatically whenever you run an npm install.

The server side is not available in TypeScript yet.

Those angular typings could be added.