You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to use the module augmentation feature of typescript in the context of a library project that is using @parcel/transformer-typescript-types to generate a .d.ts file, parcel will output an incorrect .d.ts file with many elements missing.
import{Person}from"library-original";Person.prototype.greet=function(){return`Hello ${this.name}!`}// This will be present in the .d.ts file generated by parcel:exportconstanotherThing: string="hello";// This will get dropped:declaremodule"library-original"{interfacePerson{greet(): string;}}// This will also get dropped, if the "declare module" statement above is present:exportconstsomethingElse: string="goodbye";
🤔 Expected Behavior
Parcel should ouput a complete .d.ts file, similar to tsc:
The text was updated successfully, but these errors were encountered:
astegmaier
changed the title
Trying to augment a module causes @parcel/transformer-typescript-types to output mostly blank .d.ts file
Trying to augment a module causes @parcel/transformer-typescript-types to output a mostly blank .d.ts file
Nov 16, 2021
🐛 bug report
If you try to use the module augmentation feature of typescript in the context of a library project that is using
@parcel/transformer-typescript-types
to generate a.d.ts
file, parcel will output an incorrect.d.ts
file with many elements missing.🎛 Configuration (.babelrc, package.json, cli command)
Create a
library-original
package with the following export:Build a
library-augmenter
package with parcel:package.json
src/index.ts
🤔 Expected Behavior
Parcel should ouput a complete
.d.ts
file, similar totsc
:😯 Current Behavior
Parcel outputs a
.d.ts
file that is missing both the module augmentation code and any other exports that are declared after it:💁 Possible Solution
It looks like we're doing some tree shaking of the
.d.ts
file in these lines, and we probably didn't account for this case.parcel/packages/transformers/typescript-types/src/TSTypesTransformer.js
Lines 58 to 69 in 145bfb8
🔦 Context
I was trying to help answer this question on stackoverflow
💻 Code Sample
See this repo for a reproduction of the issue.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: