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

typesVersions should not be affected by "types": "" #28304

Closed
ghost opened this issue Nov 1, 2018 · 1 comment · Fixed by #31539
Closed

typesVersions should not be affected by "types": "" #28304

ghost opened this issue Nov 1, 2018 · 1 comment · Fixed by #31539
Assignees
Labels
Bug A bug in TypeScript

Comments

@ghost
Copy link

ghost commented Nov 1, 2018

TypeScript Version: 3.2.0-dev.20181101

Code

(This is just typesVersions.justIndex.ts plus "types": "",)

// @baseUrl: /
// @traceResolution: true
// @target: esnext
// @module: commonjs

// @filename: /a/package.json
{
    "types": "",
    "typesVersions": {
        ">=3.1.0-0": { "*" : ["ts3.1/*"] }
    }
}

// @filename: /a/ts3.1/index.d.ts
export const a = 0;

// @filename: /b/user.ts
import { a } from "a";

Expected behavior:

No error.

Actual behavior:

Module resolution fails. The trace indicates that it is now looking for a file named "*.d.ts" instead of parsing the pattern correctly.

@rbuckton
Copy link
Member

rbuckton commented May 22, 2019

According to the documentation for Node's module resolution:

LOAD_AS_DIRECTORY(X)
1. If X/package.json is a file,
   a. Parse X/package.json, and look for "main" field.
   b. If "main" is a falsy value, GOTO 2.
   c. let M = X + (json main field)
   d. LOAD_AS_FILE(M)
   e. LOAD_INDEX(M)
   f. LOAD_INDEX(X) DEPRECATED
   g. THROW "not found"
2. LOAD_INDEX(X)

Step 1.b. indicates we should ignore a "falsy" value for "main", and we should probably do the same for "types", however in both cases we only check for undefined and allow "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants