Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14896,7 +14896,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const resolved = resolveAlias(aliasSymbol);
if (resolved && resolved.flags & SymbolFlags.TypeAlias) {
newAliasSymbol = resolved;
aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node);
aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node) || (typeParameters ? [] : undefined);
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions tests/baselines/reference/fixCrashAliasLookupForDefauledImport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//// [tests/cases/compiler/fixCrashAliasLookupForDefauledImport.ts] ////

//// [input.ts]
export type Foo<T = string> = {};

//// [usage.ts]
import {Foo} from "./input";

function bar<T>(element: Foo) {
return 1;
}

bar(1 as Foo<number>);


//// [input.js]
"use strict";
exports.__esModule = true;
//// [usage.js]
"use strict";
exports.__esModule = true;
function bar(element) {
return 1;
}
bar(1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== tests/cases/compiler/input.ts ===
export type Foo<T = string> = {};
>Foo : Symbol(Foo, Decl(input.ts, 0, 0))
>T : Symbol(T, Decl(input.ts, 0, 16))

=== tests/cases/compiler/usage.ts ===
import {Foo} from "./input";
>Foo : Symbol(Foo, Decl(usage.ts, 0, 8))

function bar<T>(element: Foo) {
>bar : Symbol(bar, Decl(usage.ts, 0, 28))
>T : Symbol(T, Decl(usage.ts, 2, 13))
>element : Symbol(element, Decl(usage.ts, 2, 16))
>Foo : Symbol(Foo, Decl(usage.ts, 0, 8))

return 1;
}

bar(1 as Foo<number>);
>bar : Symbol(bar, Decl(usage.ts, 0, 28))
>Foo : Symbol(Foo, Decl(usage.ts, 0, 8))

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== tests/cases/compiler/input.ts ===
export type Foo<T = string> = {};
>Foo : Foo<T>

=== tests/cases/compiler/usage.ts ===
import {Foo} from "./input";
>Foo : any

function bar<T>(element: Foo) {
>bar : <T>(element: Foo) => number
>element : Foo

return 1;
>1 : 1
}

bar(1 as Foo<number>);
>bar(1 as Foo<number>) : number
>bar : <T>(element: Foo) => number
>1 as Foo<number> : Foo<number>
>1 : 1

11 changes: 11 additions & 0 deletions tests/cases/compiler/fixCrashAliasLookupForDefauledImport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @filename: input.ts
export type Foo<T = string> = {};

// @filename: usage.ts
import {Foo} from "./input";

function bar<T>(element: Foo) {
return 1;
}

bar(1 as Foo<number>);