Use project relative preference for declaration emit (#42232)

* Test where relative import isnt ideal in the declaration emit

* use project relative preference for declaration emit
Fixes #39117

* Fix incorrect path matching when calculating module specifier

* Use correct baseUrl for the module specifier
This commit is contained in:
Sheetal Nandi
2021-04-30 13:22:05 -07:00
committed by GitHub
parent c96b472e0b
commit 54096bdb96
7 changed files with 200 additions and 8 deletions

View File

@@ -0,0 +1,44 @@
// @filename: packages/core/src/index.d.ts
export * from "./utils";
export { default as SvgIcon } from "./SvgIcon";
// @filename: packages/core/src/SvgIcon.d.ts
import { StyledComponentProps } from "@ts-bug/styles";
export interface SvgIconProps extends StyledComponentProps<"root"> {
children?: string[];
}
export interface SomeInterface {
myProp: string;
}
declare const SvgIcon: SomeInterface;
export default SvgIcon;
// @filename: packages/core/src/utils.d.ts
import SvgIcon from "./SvgIcon";
export function createSvgIcon(path: string, displayName: string): typeof SvgIcon;
// @filename: packages/styles/src/index.d.ts
export interface StyledComponentProps<ClassKey extends string> {
classes?: Record<ClassKey, string>;
}
// @filename: packages/lab/src/index.ts
import { createSvgIcon } from "@ts-bug/core/utils";
export default createSvgIcon("Hello", "ArrowLeft");
// @filename: packages/lab/tsconfig.json
{
"compilerOptions": {
"outDir": "dist",
"declaration": true,
"baseUrl": "../",
"paths": {
"@ts-bug/core": ["./core/src"],
"@ts-bug/core/*": ["./core/src/*"],
"@ts-bug/lab": ["./lab/src"],
"@ts-bug/lab/*": ["./lab/src/*"],
"@ts-bug/styles": ["./styles/src"],
"@ts-bug/styles/*": ["./styles/src/*"]
}
}
}