-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
TypeScript Version: 3.4.1
Search Terms:
Code
// @filename: types.ts
declare module '*.foo' {
let foo: string;
}
// @filename: test.ts
import {foo as a1, bar as a2} from 'a.foo';
import {foo as b1, bar as b2} from 'b.foo'; // expected error: 'b.foo' has no exported member 'bar'
declare module 'a.foo' {
let bar: number;
}
tsconfig.json
is the default config from tsc --init
Expected behavior:
I want to augment a.foo
with an exported member bar
. Importing foo
and bar
from module a.foo
succeeds while bar
is not present in module b.foo
Actual behavior:
The module augmentation a.foo
merges with the pattern ambient module *.foo
. Every module matching the pattern now has an exported member bar
.
To limit the effect to only a.foo
I need to convert the module augmentation to an ambient module and redeclare all members of the pattern ambient module because there's merging of ambient modules and pattern ambient modules.
Note: This is not an actual issue in one of my projects, I just happened to notice this surprising behavior while playing around with module resolution.