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

[dev] Fix missing types from node_modules with at-loader on Windows #2367

Merged
merged 1 commit into from
Apr 16, 2018

Conversation

reiv
Copy link
Contributor

@reiv reiv commented Apr 5, 2018

Changes proposed in this pull request:

This PR fixes a bug that affects at-loader on Windows: typings from node_modules aren't loaded automatically as they are in other environments, resulting in many errors during compilation, primarily when running unit tests. For example, running yarn test in the core package produces 836 errors, because the namespace for Mocha isn't loaded:

ERROR in [at-loader] ./test/alert/alertTests.tsx:15:1
    TS2304: Cannot find name 'describe'.

ERROR in [at-loader] ./test/alert/alertTests.tsx:16:5
    TS2304: Cannot find name 'it'.

...

(Note that tsc still emits correct code, but the type-checking process fails).

The fix is to explicitly instruct tsc to look in node_modules/@types for type declarations, which is something it should already be doing by default.

@reiv
Copy link
Contributor Author

reiv commented Apr 5, 2018

Fix missing types with at-loader on Windows

Preview: documentation | landing | table

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok cool this is nice. is there an issue on at-loader that we can reference?

@reiv
Copy link
Contributor Author

reiv commented Apr 13, 2018

@giladgray not that I know of. I only found this one #2356 (comment) from angular-starter, where I got the fix from.

@giladgray
Copy link
Contributor

@reiv i think you pasted the wrong link above?

@reiv
Copy link
Contributor Author

reiv commented Apr 16, 2018

@giladgray
Copy link
Contributor

@reiv thanks for the link. before merging this, would you mind trying one thing? upgrade awesome-typescript-loader to at least v4.0 for webpack 3 support (https://github.com/s-panferov/awesome-typescript-loader/releases). wondering if this bug has already been fixed?

@reiv
Copy link
Contributor Author

reiv commented Apr 16, 2018

@giladgray I just gave that a try.

λ yarn list --pattern awesome-typescript-loader
yarn list v1.5.1
└─ awesome-typescript-loader@4.0.1

It didn't fix the issue and now a lot more type definitions can't be found, including node_modules/typescript/lib/lib.*.d.ts and even these globals:

ERROR in [at-loader] TS2318: Cannot find global type 'Array'.
ERROR in [at-loader] TS2318: Cannot find global type 'Boolean'.
ERROR in [at-loader] TS2318: Cannot find global type 'Function'.
ERROR in [at-loader] TS2318: Cannot find global type 'IArguments'.
ERROR in [at-loader] TS2318: Cannot find global type 'Number'.
ERROR in [at-loader] TS2318: Cannot find global type 'Object'.
ERROR in [at-loader] TS2318: Cannot find global type 'RegExp'.
ERROR in [at-loader] TS2318: Cannot find global type 'String'.

It's really quite befuddling.

@giladgray
Copy link
Contributor

@reiv yuck. alright let's merge this!

@giladgray giladgray merged commit d24e88e into palantir:develop Apr 16, 2018
@reiv reiv deleted the patch-1 branch April 16, 2018 19:18
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants