Skip to content

Commit fa14b3b

Browse files
authored
fix: Fix assertion when assigning an object literal to an interface (#2197)
1 parent c740610 commit fa14b3b

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/compiler.ts

+7
Original file line numberDiff line numberDiff line change
@@ -8631,6 +8631,13 @@ export class Compiler extends DiagnosticEmitter {
86318631
}
86328632
var classType = classReference.type;
86338633
this.currentType = classType.nonNullableType;
8634+
if (classReference.kind == ElementKind.INTERFACE) {
8635+
this.error(
8636+
DiagnosticCode.Not_implemented_0,
8637+
expression.range, "Interface hidden classes"
8638+
);
8639+
return module.unreachable();
8640+
}
86348641
if (classReference.is(CommonFlags.ABSTRACT)) {
86358642
this.error(
86368643
DiagnosticCode.Cannot_create_an_instance_of_an_abstract_class,

tests/compiler/issues/2085.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"asc_flags": [
3+
],
4+
"stderr": [
5+
"AS100: Not implemented: Interface hidden classes",
6+
"EOF"
7+
]
8+
}

tests/compiler/issues/2085.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface Foo {}
2+
const foo: Foo = {};
3+
ERROR("EOF");

0 commit comments

Comments
 (0)