Microsoft/TypeScript
GitHub ã§èŠãConflict between imported namespace and global type in generated declaration file
Open
#48,121 opened on 2022幎3æ4æ¥
BugDomain: Declaration EmitHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
namespace import declaration conflict global types date-fns
ð Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about declaration files
⯠Playground Link
Playground link with relevant code
ð» Code
locale.ts:
export type T = {};
types.d.ts:
type Locale = {
code?: string
}
declare module 'date-fns/locale' {
const es: Locale
namespace es {}
}
main.ts:
import { es } from "date-fns/locale";
import * as Locale from "./locale";
export const f = (locale: Locale.T) => es;
Run tsc with "declaration": true.
ð Actual behavior
tsc runs with no errors, but the following main.d.ts file is generated:
import * as Locale from "./locale";
export declare const f: (locale: Locale.T) => Locale;
When we try to use this .d.ts file in another TS project we get this error:
Cannot use namespace 'Locale' as a type
ð Expected behavior
No conflict. Perhaps the namespace import should be renamed in the .d.ts file.