Skip to content

Commit d0ae03c

Browse files
authored
Handle import types in serializeType (microsoft#24701)
1 parent e6268f2 commit d0ae03c

6 files changed

Lines changed: 67 additions & 0 deletions

File tree

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,7 @@ namespace ts {
19121912
case SyntaxKind.AnyKeyword:
19131913
case SyntaxKind.UnknownKeyword:
19141914
case SyntaxKind.ThisType:
1915+
case SyntaxKind.ImportType:
19151916
break;
19161917

19171918
default:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests/cases/compiler/metadataImportType.ts(2,6): error TS2304: Cannot find name 'test'.
2+
tests/cases/compiler/metadataImportType.ts(3,8): error TS2307: Cannot find module './b'.
3+
4+
5+
==== tests/cases/compiler/metadataImportType.ts (2 errors) ====
6+
export class A {
7+
@test
8+
~~~~
9+
!!! error TS2304: Cannot find name 'test'.
10+
b: import('./b').B
11+
~~~~~~~~~~~~~~~
12+
!!! error TS2307: Cannot find module './b'.
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//// [metadataImportType.ts]
2+
export class A {
3+
@test
4+
b: import('./b').B
5+
}
6+
7+
//// [metadataImportType.js]
8+
"use strict";
9+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13+
return c > 3 && r && Object.defineProperty(target, key, r), r;
14+
};
15+
var __metadata = (this && this.__metadata) || function (k, v) {
16+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17+
};
18+
exports.__esModule = true;
19+
var A = /** @class */ (function () {
20+
function A() {
21+
}
22+
__decorate([
23+
test,
24+
__metadata("design:type", Object)
25+
], A.prototype, "b");
26+
return A;
27+
}());
28+
exports.A = A;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/metadataImportType.ts ===
2+
export class A {
3+
>A : Symbol(A, Decl(metadataImportType.ts, 0, 0))
4+
5+
@test
6+
b: import('./b').B
7+
>b : Symbol(A.b, Decl(metadataImportType.ts, 0, 16))
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/metadataImportType.ts ===
2+
export class A {
3+
>A : A
4+
5+
@test
6+
>test : any
7+
8+
b: import('./b').B
9+
>b : any
10+
>B : No type information available!
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @experimentalDecorators: true
2+
// @emitDecoratorMetadata: true
3+
export class A {
4+
@test
5+
b: import('./b').B
6+
}

0 commit comments

Comments
 (0)