Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Path Resolution for Type Imports in TypeScript Declarations #57956

Closed
xlianghang opened this issue Mar 27, 2024 · 2 comments Β· Fixed by #57973
Closed

Incorrect Path Resolution for Type Imports in TypeScript Declarations #57956

xlianghang opened this issue Mar 27, 2024 · 2 comments Β· Fixed by #57973
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@xlianghang
Copy link

xlianghang commented Mar 27, 2024

πŸ”Ž Search Terms

"specifier", "relative path"

πŸ•— Version & Regression Information

⏯ Playground Link

https://github.com/xlianghang/ts-specifier-bug

πŸ’» Code

//src/main.ts
import { PartialType } from './utils';

class Common {}

export class Sub extends PartialType(Common) {
  id: string;
}
// src/utils/index.ts
import { MyType, MyReturnType } from './type-helpers';

export function PartialType<T>(classRef: MyType<T>) {
  abstract class PartialClassType {
    constructor() {}
  }

  return PartialClassType as MyReturnType;
}
// src/utils/type-helpers.ts
export type MyReturnType = {
  new (...args: any[]): any;
};

export interface MyType<T = any> extends Function {
  new (...args: any[]): T;
}

πŸ™ Actual behavior

image

The dist folder is not the root directory, so do not import from src

πŸ™‚ Expected behavior

image

Import from a relative path

Additional information about the issue

Compilation fails in the MacOS, but is expected to behave in the https://stackblitz.com/~/github.com/xlianghang/ts-specifier-bug

πŸ’» MacOS 14.3,Apple M2 Max

@Boyban
Copy link

Boyban commented Mar 27, 2024

Got related problems, tRPC types inference in monorepo are not working since installing 5.4.0-dev.20231222.

I got any instead of my inferred types.

Additional information

πŸ’» MacOS 14.3.1,Apple M3

@fatcerberus
Copy link

This is the second time a .d.ts emit bug has been traced to #55015: #57926 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
5 participants