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

Compile errors with 2.0.2 (worked with 2.0.0) #10633

Closed
jmc265 opened this issue Aug 31, 2016 · 18 comments
Closed

Compile errors with 2.0.2 (worked with 2.0.0) #10633

jmc265 opened this issue Aug 31, 2016 · 18 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@jmc265
Copy link

jmc265 commented Aug 31, 2016

TypeScript Version: 2.0.0 --> 2.0.2

Expected behavior: Code compiles!

Actual behavior: Code compiles when using 2.0.0. Code does not compile when using 2.0.2.

When specifying "typescript": "2.0.0" in my package.json, all my projects compile absolutely fine (as they have been doing for some time).
However, when I upgrade (i.e. use either "typescript": "^2.0.0" or "typescript": "2.0.2") I get a lot of compile errors of the form:

ERROR in [default]                                                                                                                      
Cannot find global type 'Array'.                                                                                                        

ERROR in [default]                                                                                                                      
Cannot find global type 'Boolean'.                                                                                                      

ERROR in [default]                                                                                                                      
Cannot find global type 'Function'.                                                                                                     

ERROR in [default]                                                                                                                      
Cannot find global type 'IArguments'.                                                                                                   

ERROR in [default]                                                                                                                      
Cannot find global type 'Number'.                                                                                                       

ERROR in [default]                                                                                                                      
Cannot find global type 'Object'.                                                                                                       

ERROR in [default]                                                                                                                      
Cannot find global type 'RegExp'.                                                                                                       

ERROR in [default]                                                                                                                      
Cannot find global type 'String'.   

ERROR in [default] /Users/james/Documents/Workspace/.../node_modules/@types/axios/index.d.ts:42:18             
Cannot find name 'Object'. 

ERROR in [default] /Users/james/Documents/Workspace/.../node_modules/@types/q/index.d.ts:199:43                
Cannot find name 'Function'.               

ERROR in [default] /Users/james/Documents/Workspace/.../node_modules/typescript/lib/lib.es2015.d.ts:17:0       
File '/Users/james/Documents/Workspace/.../node_modules/typescript/lib/lib.es2015.core.d.ts' not found.       

ERROR in [default] /Users/james/Documents/Workspace/.../src/walletBar.ts:65:22                                 
Cannot find name 'Error'. 

Not sure what else I can provide to help debug this, let me know and I'll get it.

Thanks.

@kjackson87
Copy link
Member

I haven't had time to research the errors in my own typescript project, but I'm getting largely the same ones as you. Just wanted to throw it out there that I'm seeing very similar results.

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Aug 31, 2016
@RyanCavanaugh
Copy link
Member

It really looks like you're compiling with some other tool; TypeScript does not produce errors that look like that. With it being unable to find lib.d.ts, it sounds like a problem with that tool not knowing how to resolve lib references correctly. What are you using to build with?

@jmc265
Copy link
Author

jmc265 commented Aug 31, 2016

I am using webpack. Most of the projects I am building use webpack via angular-cli. But one project uses webpack directly and it is still getting the errors above when using 2.0.2.

Edit: I should probably note that I think angular-cli is using "awesome-typescript-loader" for webpack. And that is what my standalone project is using as well.

@kjackson87
Copy link
Member

I am also using webpack.

@RyanCavanaugh
Copy link
Member

Can you post a config file or something to help me bootstrap a repro? Odds are this is an issue with a webpack plugin but we'll need to track down the owner and let them know what to fix

@jmc265
Copy link
Author

jmc265 commented Aug 31, 2016

Sure, here is my webpack.config.dev.js:

var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    entry: './src/main.ts',
    output: {
        path: './build',
        publicPath: '/build/',
        filename: 'bundle.js'
    },
    devtool: 'source-map',
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
    },
    module: {
        loaders: [
            {   
                test: /\.ts$/,
                loader: 'awesome-typescript-loader'
            },
            { 
                test: /\.json$/, 
                loader: 'json-loader'
            },
            {
                test: /\.html$/,
                loader: 'html-loader'
            }
        ]
    }
}

My package.json looks like:

{
  "name": "...",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "./bin/build.sh dev && webpack-dev-server --inline --hot --quiet --port 8007 --config config/webpack.config.dev.js --content-base build",
    "build": "./bin/build.sh prod"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/q": "0.0.28",
    "@types/requirejs": "^2.1.26",
    "awesome-typescript-loader": "^2.1.1",
    "copy-webpack-plugin": "^3.0.1",
    "html-loader": "^0.4.3",
    "json-loader": "^0.5.4",
    "require": "^2.4.20",
    "requirejs": "^2.2.0",
    "typescript": "2.0.0",
    "webpack": "2.1.0-beta.18",
    "webpack-dev-server": "2.1.0-beta.0"
  },
  "dependencies": {
    "@types/axios": "^0.9.29",
    "axios": "^0.13.1",
    "q": "^1.4.1"
  }
}

Note: this has the very specific Typescript version of 2.0.0, so the above should work. If it was changed to 2.0.2, the compile errors will then happen.

I run the webpack through npm start or through this:
node_modules/webpack/bin/webpack.js --progress --hide-modules --config config/webpack.config.dev.js

@RyanCavanaugh RyanCavanaugh removed the Needs More Info The issue still hasn't been fully clarified label Aug 31, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Aug 31, 2016

@s-panferov any ideas what is going on here?

@mhegazy mhegazy added the Bug A bug in TypeScript label Aug 31, 2016
@mhegazy mhegazy self-assigned this Aug 31, 2016
@mhegazy mhegazy added this to the TypeScript 2.0.3 milestone Aug 31, 2016
@don-bluelinegrid
Copy link

@RyanCavanaugh @s-panferov @mhegazy

I also have this exact problem.

I am running a webpack build for a project based on the Aurelia framework. A build that previously worked fine with no errors using typescript@v2.0.0 immediately started to fail with the same sort of errors, when I updated to typescript@v2.0.2. I am attaching my webpack config, typescript config, and package.json.

This is definitely related to a change between v2.0.0 and v2.0.2. In my package.json I am specifying typescript v2.0.0, to have a working build, changing this to ^2.0.0, which will install v2.0.2, cause the build to fail.

Don

package.json.txt
tsconfig.json.txt
webpack.config.js.txt

@mhegazy
Copy link
Contributor

mhegazy commented Aug 31, 2016

Would you be able to share the project?

@don-bluelinegrid
Copy link

@mhegazy

I provided the package.json, tsconfig, and webpack.config.
Are you saying that you would like access to my commercial GitHub repo?

Don

@mhegazy
Copy link
Contributor

mhegazy commented Aug 31, 2016

Are you saying that you would like access to my commercial GitHub repo?

not necessarily. i would like to have access to sample that reproduces the issue. helps us debug the problem.

@juanevp
Copy link

juanevp commented Sep 1, 2016

I had the same problem (and some related). I attach a minimal project which reproduces 3 of my problems. If you npm install && webpack there should be many errores. Most of them go away if I delete the lib compiler option. Still it won't find node typings and the custom typing I reference. Even after adding

    "typeRoots": [
        "../node_modules/@types"
    ],

It won't detect the typing.
And what is buffling with the custom typing is that it says that the file name does not exist (which it does):

ERROR in [default] e:\dev\TsTest\src\main.ts:1:0
File 'e:/dev/TsTest/typings/custom-typings.d.ts' not found.

TsTest.zip

@ccrowhurstram
Copy link

I'm also experiencing the same problem. My setup is similar to @jmc265.

To reproduce the problem:

  1. Clone ng-table
  2. Checkout: git checkout 3544878b408182afb899ac076ee1ac4819a2b950
  3. Install dependencies: npm install && npm run setup
  4. Run webpack: npm run build

You should see the following errors:

image

christianacca pushed a commit to esvit/ng-table that referenced this issue Sep 1, 2016
2.0.2 is currently breaking us
(see microsoft/TypeScript#10633)
@mhegazy
Copy link
Contributor

mhegazy commented Sep 1, 2016

The issue is wrong implementation of LanguageServiceHost.resolveTypeReferenceDirectives in awesome-typescript-loader. @s-panferov any thoguhts?

@mhegazy mhegazy added the External Relates to another program, environment, or user action which we cannot control. label Sep 2, 2016
@mhegazy mhegazy removed their assignment Sep 2, 2016
@mhegazy mhegazy removed this from the TypeScript 2.0.3 milestone Sep 2, 2016
@s-panferov
Copy link

I'll take a look soon.

@jpzwarte
Copy link

The awesome-typescript-loader loader had a problem working with 2.0.2. That has since been fixed in a newer version. Have you tried that?

@Delagen
Copy link

Delagen commented Sep 12, 2016

Yes, it works now

@mhegazy
Copy link
Contributor

mhegazy commented Sep 12, 2016

Thanks for reporting back. closing.

@mhegazy mhegazy closed this as completed Sep 12, 2016
@RyanCavanaugh RyanCavanaugh removed the Bug A bug in TypeScript label Sep 13, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

10 participants