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

release-5.4: Revert PR 56087 #57850

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/compiler/checker.ts
Expand Up @@ -5735,12 +5735,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
* Checks if two symbols, through aliasing and/or merging, refer to the same thing
*/
function getSymbolIfSameReference(s1: Symbol, s2: Symbol) {
if (s1.flags & SymbolFlags.TypeAlias && s2.declarations?.find(isTypeAlias)) {
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
}
if (s2.flags & SymbolFlags.TypeAlias && s1.declarations?.find(isTypeAlias)) {
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
}
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
return s1;
}
Expand Down
@@ -0,0 +1,34 @@
src/index.ts(3,14): error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
src/index.ts(7,14): error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.


==== node_modules/some-dep/dist/inner.d.ts (0 errors) ====
export declare type Other = { other: string };
export declare type SomeType = { arg: Other };

==== node_modules/some-dep/dist/index.d.ts (0 errors) ====
export type OtherType = import('./inner').Other;
export type SomeType = import('./inner').SomeType;

==== node_modules/some-dep/package.json (0 errors) ====
{
"name": "some-dep",
"exports": {
".": "./dist/index.js"
}
}

==== src/index.ts (2 errors) ====
import { SomeType } from "some-dep";

export const foo = (thing: SomeType) => {
~~~
!!! error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
return thing;
};

export const bar = (thing: SomeType) => {
~~~
!!! error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
return thing.arg;
};
6 changes: 0 additions & 6 deletions tests/baselines/reference/declarationEmitUsingTypeAlias1.js
Expand Up @@ -39,9 +39,3 @@ var bar = function (thing) {
return thing.arg;
};
exports.bar = bar;


//// [index.d.ts]
import { SomeType } from "some-dep";
export declare const foo: (thing: SomeType) => import("some-dep").SomeType;
export declare const bar: (thing: SomeType) => import("some-dep").OtherType;