question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid bundle generated with module augmentation and path aliases

See original GitHub issue

Bug report

Input code

Please see this reproducer repo (requires multiple modules): https://github.com/DerGernTod/dts-bundle-generator-aliases

Expected output

export const enum Foo {
	BAZ = "baz"
}
export declare const enum Foo {
	BAR = "bar"
}
export interface Augmented {
	[Foo.BAZ]: string;
}
export interface Augmented {
	[Foo.BAR]: string;
}

export {};

Actual output

declare module "@shared/foo" {
	const enum Foo {
		BAZ = "baz"
	}
}
declare module "@shared/foo-map" {
	interface Augmented {
		[Foo.BAZ]: string;
	}
}
export declare const enum Foo {
	BAR = "bar"
}
export interface Augmented {
	[Foo.BAR]: string;
}

export {};

Additional context Running it with this config:

            noCheck: false,
            output: {
                inlineDeclareGlobals: true,
                sortNodes: true,
                noBanner: true,
                inlineDeclareExternals: true
            }

results in the error

dist/type-bundle.d.ts(8,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.
dist/type-bundle.d.ts(8,8): error TS2339: Property 'BAZ' does not exist on type 'typeof Foo'.

Error: Compiled with errors

It generates invalid augmented modules.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
timocovcommented, Jun 19, 2022

The fix has been released in v6.12.0

0reactions
timocovcommented, Jun 8, 2022

Sure, fair enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error TS2664: Invalid module name in augmentation #9748
attempt to use declare module 'jsonschema'; for the jsonschema npm package I get. error TS2664: Invalid module name in augmentation, module ...
Read more >
Invalid module name in augmentation -- error while using map ...
In your file .d.ts , just move all the import into the declare module "moduleName" {} .
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >
Documentation - Declaration Merging - TypeScript
See Modules for more information. Then the declarations in an augmentation are merged as if they were declared in the same file as...
Read more >
@parcel/transformer-css | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found