Skip to content

Typecheck does not work with typescript@next #100

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

Closed
frederikschubert opened this issue Feb 2, 2016 · 7 comments
Closed

Typecheck does not work with typescript@next #100

frederikschubert opened this issue Feb 2, 2016 · 7 comments

Comments

@frederikschubert
Copy link

Hi,
I am trying to use the new module resolution of typescript but the plugin cannot find the modules and no decorator metadata is emitted for the modules that I load from my jspm_packages directory.
I added the following overrides to my package.json:

    "devDependencies": {
      "json": "github:systemjs/[email protected]",
      "ts": "github:frankwallis/[email protected]",
      "typescript": "npm:[email protected]"
    },
    "overrides": {
      "github:frankwallis/[email protected]": {
        "dependencies": {
          "typescript": "npm:[email protected]"
        }
      },
      "npm:[email protected]": {
        "browser": {},
        "map": {
          "buffer": "@empty",
          "child_process": "@empty",
          "fs": "@empty",
          "os": "@empty",
          "path": "@empty",
          "process": "@empty",
          "readline": "@empty"
        }
      }
    }

My typescriptOptions in my config.js looks like the following:

transpiler: false,
  typescriptOptions: {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "module": "system",
    "noImplicitAny": false,
    "typeCheck": true,
    "tsconfig": true
  }

And one example path mapping from my tsconfig.json:

    "baseUrl": "./jspm_packages",
    "paths": {
      "angular2/*": [
        "npm/[email protected]/*"
      ],
    }
@frederikschubert frederikschubert changed the title Not emitting DecoratorMetadata when using typescript@next Typecheck does not work with typescript@next Feb 2, 2016
@frankwallis
Copy link
Owner

I don't understand what the issue is here, can you tell me (a) what is happening, (b) what you expect to be happening, thanks.

@frederikschubert
Copy link
Author

My editor (VSCode) and the typescript compiler in version 1.9.0-dev.20160128 can process the compilerOptions.paths and compilerOptions.baseUrl configuration correctly but it seems that the ts plugin does not use them.
I looks as the version override for the typescript compiler for the ts-plugin is not being used, because the plugin cannot find the modules that are mapped in the tsconfig.json.

So I have no errors in my editor and when compiling statically but the plugin cannot find the mapped modules when running in the browser.

@frankwallis
Copy link
Owner

The plugin does not use the paths in tsconfig.json, it uses the systemjs map configuration. The paths configuration in tsconfig.json should be derived from the systemjs configuration, but the systemjs configuration should be the source of truth IMHO.

Is the issue here specifically to do with resolving the 'typings' files in angular2 beta?

@frederikschubert
Copy link
Author

I think I may have not expressed my problem properly.
The application runs without problems using your plugin and angular2. My only problem is the type checking. Because typescripts "moduleResolution": "node" only looks for typings in the node_modules directory, it could not find the typings of modules (that ship their typings with their npm distribution) in the jspm_packages directory.
Since last week there is this addition to typescript's module resolution that is based on a baseUrl and path mappings. So to align the module resolution of systemjs and the typescript compiler, one can now specify these mappings in the tsconfig.json.

I wrote a small tool that reads the mappings in config.js and adds the needed path mappings to the tsconfig.json.
So the single source of truth is still the systemjs configuration, but now typescript can use that and we have finally intellisense with modules that were installed via jspm.

I hope this explains my issue. Thank you for responding so fast!

@frankwallis
Copy link
Owner

Thanks, I still think the problem here is to do with the angular2 typings, unfortunately due to restrictions of type-checking in the browser this is still an issue for plugin-typescript. See #102 for a full explanation. I realise this is an important issue and I'm hoping it can be resolved asap.

@frankwallis
Copy link
Owner

I believe this has been resolved by #102 and the angular2 project is now type-checking and has paths configuration which can be used in the IDE.

If you think there is still an issue here then I will reopen, thanks.

@frederikschubert
Copy link
Author

Looks good! Thank you!

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

2 participants