mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
22 lines
648 B
TypeScript
22 lines
648 B
TypeScript
//// [tests/cases/compiler/enumIndexer.ts] ////
|
|
|
|
//// [enumIndexer.ts]
|
|
enum MyEnumType {
|
|
foo, bar
|
|
}
|
|
var _arr = [{ key: 'foo' }, { key: 'bar' }]
|
|
var enumValue = MyEnumType.foo;
|
|
var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type
|
|
|
|
|
|
//// [enumIndexer.js]
|
|
"use strict";
|
|
var MyEnumType;
|
|
(function (MyEnumType) {
|
|
MyEnumType[MyEnumType["foo"] = 0] = "foo";
|
|
MyEnumType[MyEnumType["bar"] = 1] = "bar";
|
|
})(MyEnumType || (MyEnumType = {}));
|
|
var _arr = [{ key: 'foo' }, { key: 'bar' }];
|
|
var enumValue = MyEnumType.foo;
|
|
var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type
|