Skip to content

Commit

Permalink
Merge pull request #151 from pyrodogg/3.0-fixes
Browse files Browse the repository at this point in the history
3.0.1 - Various fixes
  • Loading branch information
pyrodogg authored Nov 27, 2019
2 parents 52a2f50 + dd6f8f9 commit bb21f15
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [3.0.1] - 2019-11-27

- Fix POSSIBLE_RESSOURCES typo in store definition ([#151](https://github.com/screepers/typed-screeps/pull/151))
- Remove unecessary tslint:disable rules in OpaqueTag definition ([#151](https://github.com/screepers/typed-screeps/pull/151))

## [3.0.0] - 2019-11-23

### Added
Expand Down Expand Up @@ -243,7 +248,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Initial public `npm` release.

[unreleased]: https://github.com/screepers/typed-screeps/compare/v2.5.4...HEAD
[unreleased]: https://github.com/screepers/typed-screeps/compare/v3.0.0...HEAD
[3.0.1]: https://github.com/screepers/typed-screeps/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/screepers/typed-screeps/compare/v2.5.4...v3.0.0
[2.5.4]: https://github.com/screepers/typed-screeps/compare/v2.5.3...v2.5.4
[2.5.3]: https://github.com/screepers/typed-screeps/compare/v2.5.2...v2.5.3
[2.5.2]: https://github.com/screepers/typed-screeps/compare/v2.5.1...v2.5.2
Expand Down
22 changes: 9 additions & 13 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1984,11 +1984,10 @@ interface _ConstructorById<T> extends _Constructor<T> {
(id: Id<T>): T;
}

// tslint:disable-next-line: no-namespace
declare namespace Tag {
const OpaqueTagSymbol: unique symbol;
// tslint:disable-next-line: strict-export-declare-modifiers
export class OpaqueTag<T> {

class OpaqueTag<T> {
private [OpaqueTagSymbol]: T;
}
}
Expand Down Expand Up @@ -4578,29 +4577,26 @@ interface SpawnOptions {
}

interface SpawningConstructor extends _Constructor<Spawning>, _ConstructorById<Spawning> {}
interface StoreBase<POSSIBLE_RESSOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> {
interface StoreBase<POSSIBLE_RESOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> {
/** Returns capacity of this store for the specified resource, or total capacity if resource is undefined. */
getCapacity<R extends ResourceConstant | undefined>(
resource?: R,
): UNLIMITED_STORE extends true
? null
: (undefined extends R
? (ResourceConstant extends POSSIBLE_RESSOURCES ? number : null)
: (R extends POSSIBLE_RESSOURCES ? number : null));
? (ResourceConstant extends POSSIBLE_RESOURCES ? number : null)
: (R extends POSSIBLE_RESOURCES ? number : null));
/** Returns the capacity used by the specified resource, or total used capacity for general purpose stores if resource is undefined. */
getUsedCapacity<R extends ResourceConstant | undefined>(
resource?: R,
): undefined extends R ? (ResourceConstant extends POSSIBLE_RESSOURCES ? number : null) : (R extends POSSIBLE_RESSOURCES ? number : 0);
): undefined extends R ? (ResourceConstant extends POSSIBLE_RESOURCES ? number : null) : (R extends POSSIBLE_RESOURCES ? number : 0);
/** A shorthand for getCapacity(resource) - getUsedCapacity(resource). */
getFreeCapacity(resource?: ResourceConstant): number;
}

type Store<POSSIBLE_RESSOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> = StoreBase<
POSSIBLE_RESSOURCES,
UNLIMITED_STORE
> &
{ [P in POSSIBLE_RESSOURCES]: number } &
{ [P in Exclude<ResourceConstant, POSSIBLE_RESSOURCES>]: 0 };
type Store<POSSIBLE_RESOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> = StoreBase<POSSIBLE_RESOURCES, UNLIMITED_STORE> &
{ [P in POSSIBLE_RESOURCES]: number } &
{ [P in Exclude<ResourceConstant, POSSIBLE_RESOURCES>]: 0 };

interface GenericStoreBase {
/** Returns capacity of this store for the specified resource, or total capacity if resource is undefined. */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typed-screeps",
"version": "3.0.0",
"version": "3.0.1",
"description": "Strong TypeScript declarations for the game Screeps.",
"repository": "screepers/typed-screeps",
"types": "./dist/index.d.ts",
Expand Down
5 changes: 2 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,10 @@ interface _ConstructorById<T> extends _Constructor<T> {
(id: Id<T>): T;
}

// tslint:disable-next-line: no-namespace
declare namespace Tag {
const OpaqueTagSymbol: unique symbol;
// tslint:disable-next-line: strict-export-declare-modifiers
export class OpaqueTag<T> {

class OpaqueTag<T> {
private [OpaqueTagSymbol]: T;
}
}
Expand Down
17 changes: 7 additions & 10 deletions src/store.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
interface StoreBase<POSSIBLE_RESSOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> {
interface StoreBase<POSSIBLE_RESOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> {
/** Returns capacity of this store for the specified resource, or total capacity if resource is undefined. */
getCapacity<R extends ResourceConstant | undefined>(
resource?: R,
): UNLIMITED_STORE extends true
? null
: (undefined extends R
? (ResourceConstant extends POSSIBLE_RESSOURCES ? number : null)
: (R extends POSSIBLE_RESSOURCES ? number : null));
? (ResourceConstant extends POSSIBLE_RESOURCES ? number : null)
: (R extends POSSIBLE_RESOURCES ? number : null));
/** Returns the capacity used by the specified resource, or total used capacity for general purpose stores if resource is undefined. */
getUsedCapacity<R extends ResourceConstant | undefined>(
resource?: R,
): undefined extends R ? (ResourceConstant extends POSSIBLE_RESSOURCES ? number : null) : (R extends POSSIBLE_RESSOURCES ? number : 0);
): undefined extends R ? (ResourceConstant extends POSSIBLE_RESOURCES ? number : null) : (R extends POSSIBLE_RESOURCES ? number : 0);
/** A shorthand for getCapacity(resource) - getUsedCapacity(resource). */
getFreeCapacity(resource?: ResourceConstant): number;
}

type Store<POSSIBLE_RESSOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> = StoreBase<
POSSIBLE_RESSOURCES,
UNLIMITED_STORE
> &
{ [P in POSSIBLE_RESSOURCES]: number } &
{ [P in Exclude<ResourceConstant, POSSIBLE_RESSOURCES>]: 0 };
type Store<POSSIBLE_RESOURCES extends ResourceConstant, UNLIMITED_STORE extends boolean> = StoreBase<POSSIBLE_RESOURCES, UNLIMITED_STORE> &
{ [P in POSSIBLE_RESOURCES]: number } &
{ [P in Exclude<ResourceConstant, POSSIBLE_RESOURCES>]: 0 };

interface GenericStoreBase {
/** Returns capacity of this store for the specified resource, or total capacity if resource is undefined. */
Expand Down

0 comments on commit bb21f15

Please sign in to comment.