Skip to content

Compile errors with 2.0.2 (worked with 2.0.0) #10633

Closed

Description

@jmc265

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.

Activity

  1. kjackson87 commented on Aug 31, 2016

    @kjackson87

    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.

  2. RyanCavanaugh commented on Aug 31, 2016

    @RyanCavanaugh
    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?

  3. jmc265 commented on Aug 31, 2016

    @jmc265
    Author

    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.

  4. kjackson87 commented on Aug 31, 2016

    @kjackson87

    I am also using webpack.

  5. RyanCavanaugh commented on Aug 31, 2016

    @RyanCavanaugh
    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

  6. jmc265 commented on Aug 31, 2016

    @jmc265
    Author

    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

  7. mhegazy commented on Aug 31, 2016

    @mhegazy
    Contributor

    Stanislav Panferov (@s-panferov) any ideas what is going on here?

  8. don-bluelinegrid commented on Aug 31, 2016

    @don-bluelinegrid

    Ryan Cavanaugh (@RyanCavanaugh) Stanislav Panferov (@s-panferov) Mohamed Hegazy (@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

  9. mhegazy commented on Aug 31, 2016

    @mhegazy
    Contributor

    Would you be able to share the project?

  10. don-bluelinegrid commented on Aug 31, 2016

    @don-bluelinegrid

    Mohamed Hegazy (@mhegazy)

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

    Don

  11. mhegazy commented on Aug 31, 2016

    @mhegazy
    Contributor

    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.

  12. juanevp commented on Sep 1, 2016

    @juanevp

    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

  13. ccrowhurstram commented on Sep 1, 2016

    @ccrowhurstram

    I'm also experiencing the same problem. My setup is similar to James Cross (@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

  14. mhegazy commented on Sep 1, 2016

    @mhegazy
    Contributor

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

  15. added
    ExternalRelates to another program, environment, or user action which we cannot control.
    on Sep 2, 2016
  16. s-panferov commented on Sep 5, 2016

    @s-panferov

    I'll take a look soon.

  17. jpzwarte commented on Sep 12, 2016

    @jpzwarte

    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?

  18. delagen commented on Sep 12, 2016

    @delagen

    Yes, it works now

  19. mhegazy commented on Sep 12, 2016

    @mhegazy
    Contributor

    Thanks for reporting back. closing.

  20. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions