Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the Order type to ORDER_BUY | ORDER_SELL instead of string #255

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3173,7 +3173,7 @@ interface Order {
id: string;
created: number;
active?: boolean;
type: string;
type: ORDER_BUY | ORDER_SELL;
resourceType: MarketResourceConstant;
roomName?: string;
amount: number;
Expand Down
15 changes: 15 additions & 0 deletions dist/screeps-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,21 @@ function resources(o: GenericStore): ResourceConstant[] {
Game.market.createOrder({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000, roomName: "W1N1" });
Game.market.createOrder({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000 });

// Testing the hardcoded string literal value of the `type` field
{
// error
Game.market.createOrder({
// @ts-expect-error
type: "BUY",
resourceType: RESOURCE_GHODIUM,
price: 9.95,
totalAmount: 10000,
});

// okay
Game.market.createOrder({ type: "buy", resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000 });
}

// Game.market.deal(orderId, amount, [yourRoomName])
Game.market.deal("57cd2b12cda69a004ae223a3", 1000, "W1N1");

Expand Down
2 changes: 1 addition & 1 deletion src/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ interface Order {
id: string;
created: number;
active?: boolean;
type: string;
type: ORDER_BUY | ORDER_SELL;
resourceType: MarketResourceConstant;
roomName?: string;
amount: number;
Expand Down
Loading