Skip to content

Support loading "index.d.ts" using "typesVersions" without "types", "typings", or "main"#27514

Merged
2 commits merged into
masterfrom
typesVersions_index
Oct 3, 2018
Merged

Support loading "index.d.ts" using "typesVersions" without "types", "typings", or "main"#27514
2 commits merged into
masterfrom
typesVersions_index

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Oct 3, 2018

Currently "typesVersions" effectively has no effect unless "types", "typings", or "main" is specified in package.json. But we don't normally require those fields if index.d.ts is present. This PR makes "index" the default if none of those fields is specified.

(This should make it easier to add a minimal package.json with types redirects to DefinitelyTyped packages without having to add "types": "index". Those packages should still work without this PR once published because we'll generate a full, verbose package.json automatically when publishing, but it's nice to have the user-written package.jsons on DefinitelyTyped minimal.)

@ghost ghost requested a review from rbuckton October 3, 2018 00:59
@rbuckton
Copy link
Copy Markdown
Contributor

rbuckton commented Oct 3, 2018

In general I think this looks fine, but it seems you have a test failure.

"File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/other.ts' does not exist.",
"File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/other.tsx' does not exist.",
"File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/other.d.ts' does not exist.",
"'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this message will change everytime we change the compiler version (because of version of compiler being in the message) so if we forget about it every version change will introduce test failure?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Not sure what we can do about this besides change the message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use sanitizeTraceResolutionLogEntry in harness/utils.ts to normalize the message for test runs. Its already in use in the compiler/conformance tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather, its already being used here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nothing to do? @sheetalkamat @rbuckton Good to merge?

@ghost ghost merged commit 9bdd6a3 into master Oct 3, 2018
@ghost ghost deleted the typesVersions_index branch October 3, 2018 18:44
ghost pushed a commit that referenced this pull request Oct 4, 2018
…typings", or "main" (#27514)

* Support loading "index.d.ts" using "typesVersions" without "types", "typings", or "main"

* Update baseline
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants