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

Cannot find typings with typescript@beta and @type #247

Closed
sanex3339 opened this issue Jul 17, 2016 · 20 comments
Closed

Cannot find typings with typescript@beta and @type #247

sanex3339 opened this issue Jul 17, 2016 · 20 comments

Comments

@sanex3339
Copy link
Contributor

sanex3339 commented Jul 17, 2016

My problem same as in #243

After installing @types/node i got multiple errors:

(1,21): error TS2307: Cannot find module 'fs'.
(3,23): error TS2307: Cannot find module 'path'.
(80,41): error TS2304: Cannot find name 'process'.
(5,12): error TS2304: Cannot find name 'global'.
(6,5): error TS2304: Cannot find name 'require'.

I add all definitions to types

But as said https://github.com/mhegazy in DefinitelyTyped/DefinitelyTyped#10113 (comment)

you should not need to add the types property, the behavior should be the same with or without it

2.0.0-beta compiler.

project: https://github.com/sanex3339/javascript-obfuscator/tree/dev

project tsconfig:

{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": true
  }
}

entry point

"use strict";

import { JavaScriptObfuscator } from './src/JavaScriptObfuscator';

if (!(<any>global)._babelPolyfill) {
    require('babel-polyfill');
}

module.exports = JavaScriptObfuscator;

to reproduce you must clone dev branch, and run node_modules/.bin/webpack --watch

@brunolm
Copy link

brunolm commented Jul 19, 2016

I have the same issue.

I also had issues on VSCode, but they helped me to solve that by doing this: microsoft/TypeScript#9725 (comment)

But this is not enough to solve ts-loader issue

@theduke
Copy link

theduke commented Aug 19, 2016

As specified in #243, adding

  "compilerOptions": {
    ...
    "types": ["react", ...]
  } 

to tsconfig.json makes it work, but this should clearly not be neccessary, since tsc on itself works fine.

@gxsjtu
Copy link

gxsjtu commented Sep 5, 2016

any update?
It is redundant to declare types in tsconfig.

@blakeembrey
Copy link
Member

I believe this is a fairly trivial fix to do, but I haven't been working on the project as the state of the tests are broken. If someone would care to improve the situation, I can work on new features.

@HerringtonDarkholme
Copy link
Contributor

I have a fork to support TypeScript in Vue. I have fixed most tests in TS1.8. https://github.com/HerringtonDarkholme/vue-ts-loader

@HerringtonDarkholme
Copy link
Contributor

HerringtonDarkholme commented Sep 9, 2016

I believe this is a fairly trivial fix to do

Yes, I have tried add @types support. Quite easy to implement.

But the tests are really really fragile....

@blakeembrey
Copy link
Member

Yes, the tests are a pain for me also. The implementation for ts-node is TypeStrong/ts-node@240d4b9, so it shouldn't be hard to add, but with the current state of the tests I'm hesitant to work on it without knowing I won't break something else. Hoping @jbrantly will be able to help with the situation 😄

@quantuminformation
Copy link

any ideas how to fix this:

├── ts-loader@0.8.2
└── UNMET PEER DEPENDENCY webpack@2.1.0-beta.21

@blakeembrey
Copy link
Member

blakeembrey commented Sep 10, 2016

@quantuminformation Please don't fill up issues with unrelated problems. If you need help, there's Gitter, Google or a new issue.

Most likely, some package you've installed specifies a peer dependency on webpack that is different to the version you have installed.

Edit: If you did an npm ls, which it looks like you did, it probably says along the bottom what the issue is. For instance, mine says "peer dep missing: x@x, required by x@x".

@gxsjtu
Copy link

gxsjtu commented Sep 13, 2016

@HerringtonDarkholme could you please make a PR, then the function can be merged to master branch.

@theduke
Copy link

theduke commented Sep 17, 2016

I figured it out, guys.

It starts working with the following compilerOption settings:

"moduleResolution": "node",
"allowSyntheticDefaultImports": true,

@icfantv
Copy link

icfantv commented Oct 1, 2016

@theduke setting those flags does not work for us. this still feels like a bug in ts-loader.

@marekpw
Copy link

marekpw commented Oct 1, 2016

Any news on this? Typescript 2 is no longer in beta and typings are deprecated.

@HerringtonDarkholme
Copy link
Contributor

My fork has added types support, but still cannot get all tests passed. You can also have a look on awesome typescript loader.

@icfantv
Copy link

icfantv commented Oct 2, 2016

We switched to ATL and it works fine.

@marekpw
Copy link

marekpw commented Oct 2, 2016

Can also confirm that ATL works fine, thanks @HerringtonDarkholme for the suggestion.

@maffelbaffel
Copy link

Same for me. ATL just worked.

@johnnyreilly
Copy link
Member

johnnyreilly commented Oct 15, 2016

Hi @HerringtonDarkholme, (or anyone else!)

Would you be interested in submitting a PR so we could get types support into ts-loader proper? We'd be glad to get this issue resolved! BTW tests should all be passing now.

@johnnyreilly
Copy link
Member

Hopefully this should be resolved by: #318

@johnnyreilly
Copy link
Member

Resolved - 🚢 with 0.9.2

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

No branches or pull requests