I want to extend string
with a method that needs an enumeration to be passed. How do I import that enum into the declaration file?
CapitalizationStyle.tsx:
export enum CapitalizationStyle {
None = 0,
Lowercase = 1,
Word = 2
}
StringExtensions.d.ts:
import { CapitalizationStyle } from "Utils/CapitalizationStyle"; //This line breaks everything.
declare interface String {
applyCapitalizationStyle(this: string, style: CapitalizationStyle): string;
}
The import breaks the interface declaration, like if the declaration does not exist anymore. All extension implementations of the String class become invalid as soon as I add the import:
StringExtensions.tsx:
Minimal reproducible example project: https://wetransfer.com/downloads/d1a707c0ac734985b877058967c35a6820171212143715/410f48
Since you don't have a default export from that module, you need to wrap it in {}
:
import { CapitalizationStyle } from "Utils/CapitalizationStyle";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With