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

webpack-env.d.ts is not included in the export to the @types/webpack npm package #10578

Closed
tobico opened this issue Aug 12, 2016 · 8 comments
Closed
Assignees
Labels

Comments

@tobico
Copy link
Contributor

tobico commented Aug 12, 2016

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/types-2.0/webpack/webpack-env.d.ts

This type definitions file is necessary when using stuff added to the module namespace by webpack, such as require, but it's not currently being included in the npm module for Typescript 2.0 at https://www.npmjs.com/package/@types/webpack

@vvakame vvakame added the @types label Aug 12, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Aug 16, 2016

There is the issue that the file webpack-env.d.ts is not included in the package, this is an easy one to fix. but there is still the question of how you get this into your compilation.

webpack-env.d.ts has a conflicting definition for require that will not allow it to be included along with node.d.ts. I am not familiar with webpack usage to be able to tell if this is correct or not.

there are two options here,

  1. in webpack/index.d.ts add a /// <reference path="webpack-env.d.ts" />, so that all imports to webpack include the env declarations, but again this means that node.d.ts can not be included.
  2. do not add a /// <reference path="webpack-env.d.ts" />, and users interested in using the env declarations need to add: /// <reference types="webpack/webpack-env" /> explicitlly, or add it to the --types list in the tsconfig.json or pass it on the commandline.

I am inclined to do 2, so let me know if you think this is not correct.

@leon
Copy link
Contributor

leon commented Sep 19, 2016

I'm having a hard time using webpack-env's Module since there is also a Module in index.d.ts

Should we rename wepack-env Module to EnvModule?

@TomMarius
Copy link

or add it to the --types list in the tsconfig.json or pass it on the commandline.

this does not work; VS Code still says it's unable to find name "require".

@use-strict
Copy link
Contributor

use-strict commented Sep 30, 2016

webpack and webpack-env are two different things and they should be split into separate packages. First one is used when you want to call webpack from your insert_favorite_build_tool_here, while the latter defines the enviroment for your project webpacked files. See #10978 (comment)

@mhegazy , webpack-env.d.ts and node.d.ts are mutually exclusive, because they represent two different environments. Webpack emulates some of the node.js APIs so you can run node.js code in the browser, but there are notable differences and hence the need to have a separate webpack-env file.

@stephtr
Copy link
Contributor

stephtr commented Sep 30, 2016

or add it to the --types list in the tsconfig.json or pass it on the commandline.

this does not work; VS Code still says it's unable to find name "require".

In VS Code it does not work, but when compiling with webpack it works.

@iotch
Copy link

iotch commented Oct 1, 2016

There is another issue with webpack-env.d.ts - error TS2339: Property 'catch' does not exist on type 'void' but webpack 2 now returns a Promise instance from require.ensure() instead of void.

@use-strict
Copy link
Contributor

Fixed with #11684

@use-strict
Copy link
Contributor

@iotch , I'm not sure about your error, but if it's specific to webpack2, maybe we need new/separate definitions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants