Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up`umd` format `export as namespace MyLib` does not work without `@types/*` #30199
Labels
Comments
This comment has been minimized.
This comment has been minimized.
What does "manually added" mean? Is there a tsconfig file? What is your tsc commandline? |
This comment has been minimized.
This comment has been minimized.
@RyanCavanaugh And my tsc command is simple |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I've found out how to make it work: namespaced file should be in a specific .d.ts file with root level declare namespace, and then declare module in another .d.ts file. // placeholder.js.d.ts
declare namespace placeholder {
type PlaceholderOptions = Partial<{
size: string;
bgcolor: string;
color: string;
text: string;
fstyle: string;
fweight: string;
fsize: string;
ffamily: string;
}>;
interface Placeholder {
getCanvas(options?: PlaceholderOptions): HTMLCanvasElement;
getData(options?: PlaceholderOptions): string;
render(force?: string): void;
}
}
declare const placeholder: placeholder.Placeholder;
export = placeholder;
export as namespace placeholder; // typings.d.ts
declare module 'placeholder.js' {
export = placeholder;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript Version: 3.4.0-dev.20190302
Search Terms:
export as namespace
,umd
Code
Expected behavior:
export as namespace
works forumd
formatActual behavior:
There is an error:
error TS2304: Cannot find name 'MyLib'.
But if I move
node_modules/my-lib/index.d.ts
tonode_modules/@types/my-lib/index.d.ts
, there will be no error any more.Playground Link:
Related Issues: