Merge pull request #5736 from UBC-CPEN/issue-5173

Give more helpful error when trying to set default values on an interface.
This commit is contained in:
Daniel Rosenwasser
2015-12-01 13:05:09 -08:00
10 changed files with 81 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
tests/cases/compiler/errorOnInitializerInInterfaceProperty.ts(2,19): error TS1246: An interface property cannot have an initializer.
==== tests/cases/compiler/errorOnInitializerInInterfaceProperty.ts (1 errors) ====
interface Foo {
bar: number = 5;
~
!!! error TS1246: An interface property cannot have an initializer.
}

View File

@@ -0,0 +1,7 @@
//// [errorOnInitializerInInterfaceProperty.ts]
interface Foo {
bar: number = 5;
}
//// [errorOnInitializerInInterfaceProperty.js]

View File

@@ -0,0 +1,17 @@
tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts(2,19): error TS1247: A type literal property cannot have an initializer.
tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts(6,19): error TS1247: A type literal property cannot have an initializer.
==== tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts (2 errors) ====
var Foo: {
bar: number = 5;
~
!!! error TS1247: A type literal property cannot have an initializer.
};
let Bar: {
bar: number = 5;
~
!!! error TS1247: A type literal property cannot have an initializer.
};

View File

@@ -0,0 +1,13 @@
//// [errorOnInitializerInObjectTypeLiteralProperty.ts]
var Foo: {
bar: number = 5;
};
let Bar: {
bar: number = 5;
};
//// [errorOnInitializerInObjectTypeLiteralProperty.js]
var Foo;
var Bar;

View File

@@ -0,0 +1,3 @@
interface Foo {
bar: number = 5;
}

View File

@@ -0,0 +1,7 @@
var Foo: {
bar: number = 5;
};
let Bar: {
bar: number = 5;
};