Skip to content

Resolving module declaration path should prefer d.ts over .ts #15272

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
saschanaz opened this issue Apr 19, 2017 · 1 comment
Closed

Resolving module declaration path should prefer d.ts over .ts #15272

saschanaz opened this issue Apr 19, 2017 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@saschanaz
Copy link
Contributor

TypeScript Version: master branch

Repro:

  1. Get this file and unzip: ts-module-declaration-resolving.zip
  2. Run tsc on the test subdirectory

Expected behavior:

test-output directory should only contain inner.js

Actual behavior:

test-output directory contains outer.js and test/inner.js

Why?:

import test from "../outer.js" causes this bug, it should try finding outer.d.ts before outer.ts to remove the need to recompile.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 19, 2017

.ts files are considered sources, where .d.ts are considered outputs. the compiler will always prefer a source file for an output when it is resolving modules, the rational, is that sources are more up-to-date than an output.

In general, do not put .d.ts next to your .ts if you intend to import them, use --outDir or --declrationDir instead.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Apr 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants