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

Use node module resolution for @types even when targeting non-node modules #11103

Closed
ghost opened this issue Sep 23, 2016 · 7 comments
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Sep 23, 2016

TypeScript Version: nightly (2.1.0-dev.20160923)

Code

node_modules/@types/a/index.d.ts

export declare class A {}

node_modules/@types/b/index.d.ts

import {A} from "a";
export declare class B extends A {}

tsconfig.json

{
    "compilerOptions": {
        "module": "es2015"
    }
}

src/foo.ts

May leave this empty.

Expected behavior

node_modules/@types/b/index.d.ts can reference node_modules/@types/a/index.d.ts

Actual behavior

node_modules/@types/b/index.d.ts(1,17): error TS2307: Cannot find module 'a'.

Quick fix

This may be fixed by adding "moduleResolution": "node" to tsconfig.json.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 23, 2016

I am sure we had another issue for this, but can not seem to find it.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 23, 2016

@andy-ms we should get a fix for this soon as well.

@cnshenj
Copy link

cnshenj commented Sep 23, 2016

The quick fix doesn't solve the problem when developing AMD-based projects. All modules defined in the project are in AMD format. If moduleResolution is set to node then these modules can't be imported properly.

@wizzard0
Copy link

This will also enable scenario of using Rollup.js for bundling and npm link for linking components / solution projects
(rollup requires ES6 modules, and right now emitting ES6 modules breaks Node module resolution)

@viceice
Copy link

viceice commented Oct 6, 2016

@cnshenj What is your workaround for now? We have the same problem with momentjs and knockout-decorators

@ghost ghost closed this as completed in #11147 Oct 6, 2016
@cnshenj
Copy link

cnshenj commented Oct 6, 2016

@viceice Just keep using typings to get all declaration files for AMD-based projects. Have to wait for TypeScript 2.1 to switch from typings to @types.

@viceice
Copy link

viceice commented Oct 12, 2016

@cnshenj If you use relative path then it will work. That's the workaround for me.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants