Skip to content

Commit ec8c8b8

Browse files
committed
1 parent 048029e commit ec8c8b8

6 files changed

+104
-24
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14896,7 +14896,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1489614896
const resolved = resolveAlias(aliasSymbol);
1489714897
if (resolved && resolved.flags & SymbolFlags.TypeAlias) {
1489814898
newAliasSymbol = resolved;
14899-
aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node);
14899+
aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node) || (typeParameters ? [] : undefined);
1490014900
}
1490114901
}
1490214902
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [tests/cases/compiler/fixCrashAliasLookupForDefauledImport.ts] ////
2+
3+
//// [input.ts]
4+
export type Foo<T = string> = {};
5+
6+
//// [usage.ts]
7+
import {Foo} from "./input";
8+
9+
function bar<T>(element: Foo) {
10+
return 1;
11+
}
12+
13+
bar(1 as Foo<number>);
14+
15+
16+
//// [input.js]
17+
"use strict";
18+
exports.__esModule = true;
19+
//// [usage.js]
20+
"use strict";
21+
exports.__esModule = true;
22+
function bar(element) {
23+
return 1;
24+
}
25+
bar(1);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/input.ts ===
2+
export type Foo<T = string> = {};
3+
>Foo : Symbol(Foo, Decl(input.ts, 0, 0))
4+
>T : Symbol(T, Decl(input.ts, 0, 16))
5+
6+
=== tests/cases/compiler/usage.ts ===
7+
import {Foo} from "./input";
8+
>Foo : Symbol(Foo, Decl(usage.ts, 0, 8))
9+
10+
function bar<T>(element: Foo) {
11+
>bar : Symbol(bar, Decl(usage.ts, 0, 28))
12+
>T : Symbol(T, Decl(usage.ts, 2, 13))
13+
>element : Symbol(element, Decl(usage.ts, 2, 16))
14+
>Foo : Symbol(Foo, Decl(usage.ts, 0, 8))
15+
16+
return 1;
17+
}
18+
19+
bar(1 as Foo<number>);
20+
>bar : Symbol(bar, Decl(usage.ts, 0, 28))
21+
>Foo : Symbol(Foo, Decl(usage.ts, 0, 8))
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/input.ts ===
2+
export type Foo<T = string> = {};
3+
>Foo : Foo<T>
4+
5+
=== tests/cases/compiler/usage.ts ===
6+
import {Foo} from "./input";
7+
>Foo : any
8+
9+
function bar<T>(element: Foo) {
10+
>bar : <T>(element: Foo) => number
11+
>element : Foo
12+
13+
return 1;
14+
>1 : 1
15+
}
16+
17+
bar(1 as Foo<number>);
18+
>bar(1 as Foo<number>) : number
19+
>bar : <T>(element: Foo) => number
20+
>1 as Foo<number> : Foo<number>
21+
>1 : 1
22+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @filename: input.ts
2+
export type Foo<T = string> = {};
3+
4+
// @filename: usage.ts
5+
import {Foo} from "./input";
6+
7+
function bar<T>(element: Foo) {
8+
return 1;
9+
}
10+
11+
bar(1 as Foo<number>);
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/// <reference path='fourslash.ts' />
2-
3-
// @allowJs: true
4-
// @Filename: a.js
5-
/////**
6-
//// * @type {/*a*/Foo/*b*/}
7-
//// */
8-
9-
goTo.file('a.js')
10-
goTo.select("a", "b");
11-
edit.applyRefactor({
12-
refactorName: "Extract type",
13-
actionName: "Extract to typedef",
14-
actionDescription: "Extract to typedef",
15-
newContent:
16-
`/**
17-
* @typedef {Foo} /*RENAME*/NewType
18-
*/
19-
20-
/**
21-
* @type {NewType}
22-
*/`,
23-
});
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowJs: true
4+
// @Filename: a.js
5+
/////**
6+
//// * @type {/*a*/Foo/*b*/}
7+
//// */
8+
9+
goTo.file('a.js')
10+
goTo.select("a", "b");
11+
edit.applyRefactor({
12+
refactorName: "Extract type",
13+
actionName: "Extract to typedef",
14+
actionDescription: "Extract to typedef",
15+
newContent:
16+
`/**
17+
* @typedef {Foo} /*RENAME*/NewType
18+
*/
19+
20+
/**
21+
* @type {NewType}
22+
*/`,
23+
});

0 commit comments

Comments
 (0)