mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
Enum and enum literal
This commit is contained in:
@@ -2266,7 +2266,8 @@ namespace ts {
|
||||
return createKeywordTypeNode(SyntaxKind.BooleanKeyword);
|
||||
}
|
||||
if (type.flags & TypeFlags.Enum) {
|
||||
throw new Error ("enums not implemented")
|
||||
const name = createNameFromSymbol(type.symbol);
|
||||
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
|
||||
}
|
||||
if (type.flags & (TypeFlags.StringLiteral)) {
|
||||
return createLiteralTypeNode((createLiteral((<LiteralType>type).text)));
|
||||
@@ -2278,7 +2279,8 @@ namespace ts {
|
||||
return (<IntrinsicType>type).intrinsicName === "true" ? createTrue() : createFalse();
|
||||
}
|
||||
if (type.flags & TypeFlags.EnumLiteral) {
|
||||
throw new Error("enum literal not implemented");
|
||||
const name = createNameFromSymbol(type.symbol);
|
||||
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
|
||||
}
|
||||
if (type.flags & TypeFlags.Void) {
|
||||
return createKeywordTypeNode(SyntaxKind.VoidKeyword);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @lib: es2017
|
||||
|
||||
//// enum E { a,b,c }
|
||||
//// interface I {
|
||||
//// a: E;
|
||||
//// }
|
||||
//// class C implements I {[| |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
a: E;
|
||||
`);
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @lib: es2017
|
||||
|
||||
//// enum E { a,b,c }
|
||||
//// interface I {
|
||||
//// a: E.a
|
||||
//// }
|
||||
//// class C implements I {[| |]}
|
||||
|
||||
verify.rangeAfterCodeFix(`
|
||||
a: E.a;
|
||||
`);
|
||||
Reference in New Issue
Block a user