Skip to content

Module augmentation causes import to be tree-shaken (is removed from output)Β #55481

@matthew-dean

Description

@matthew-dean

πŸ”Ž Search Terms

"module augmentation" tree-shaking

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions because: I'm using the satisfies keyword

⏯ Playground Link

https://github.com/jesscss/jess/blob/dev-freeze/packages/css-parser/src/cssParser.ts#L2

πŸ’» Code

// chevrotain.d.ts
declare module 'chevrotain' {
  interface CstParser {
    // things that augment this type
  }
}


// cssParser.ts
import { CstParser, EOF } from 'chevrotain'

class CssParser extends CstParser {
 // class implementation
}

// outputs
import { EOF } from 'chevrotain'

πŸ™ Actual behavior

Augmenting the module seems to remove it from being considered "used" when compiling.

πŸ™‚ Expected behavior

Augmenting the module should have no effect on tree-shaking imports.

Additional information about the issue

I thought maybe this was an expected behavior, and I'd just never encountered it before? But I could find nothing in TypeScript documentation about this.

Also, interestingly, the import is not tree-shaken from the exported .d.ts file, only the .js file. πŸ€·β€β™‚οΈ

Metadata

Metadata

Assignees

Labels

ExternalRelates to another program, environment, or user action which we cannot control.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions