microsoft / microsoft/TypeScript
`typesVersions` doesn't match behaviour of `exports`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
- "typesVersions"
- "exports"
🕗 Version & Regression Information
- This relates to the work around Node.js
exports(i.e. #53116). - This has never worked to my knowledge.
⏯ Playground Link
No response
💻 Code
package.json:
{
"exports": {
"./*": {
"types": "./dist/types/*/*.d.ts",
"import": "./dist/esm/*/*.js",
"require": "./dist/cjs/*/*.js"
}
},
"typesVersions": {
"*": {
"*": [
"./dist/types/*/*.d.ts"
]
}
}
}
🙁 Actual behavior
These provided export paths work as expected in Node.js. For example, I can import from foo/dist/esm/bar/bar.js with:
import { bar } from 'foo/bar';
However, TypeScript is unable to resolve the double wildcard in typesVersions. I also see a validation error on the string ("./dist/types/*/*.d.ts") in VS Code.
🙂 Expected behavior
I'd expect that typesVersions behaves the same way that exports does.
Additional information about the issue
I realise that a quick solution to this would be to use index.js in each folder instead of a file with the same name as the folder, but wanted to report the different in behaviour here.
This may also technically be a feature request.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem package.json-Beispiel und reproduziere die Auflösung des doppelten Wildcards in typesVersions entsprechend dem zugehörigen exports-Muster. Verfolge anschließend TypeScript's Behandlung dieser Felder bei der Modulauflösung und seinen Validierungspfad. Fertig ist die Aufgabe, wenn das dokumentierte Muster akzeptiert wird und konsistent mit dem Verhalten von exports aufgelöst wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- node.js, typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100