Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Prefer "overload" over "default parameter" for backward compat #259

Merged
merged 1 commit into from
Jun 4, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AssertTest extends AnyFunSpec {
}

it("have rejects/doesNotReject from v10.0.0") {
assert(NodeAssert.strict.rejects _ !== js.undefined)
assert(NodeAssert.strict.doesNotReject _ !== js.undefined)
NodeAssert.strict.rejects(js.Promise.reject("omg"))
NodeAssert.strict.doesNotReject(js.Promise.resolve[String]("wow"))
}
}
41 changes: 27 additions & 14 deletions app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Assert.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ trait Assert extends js.Object {
* @param expression the expression to evaluate
* @example assert(value[, message])
*/
def apply(expression: js.Any, message: String = js.native): Unit = js.native
def apply(expression: js.Any, message: String): Unit = js.native
def apply(expression: js.Any): Unit = js.native

/**
* Generally identical to assert.deepEqual() with two exceptions. First, primitive values are compared using the
* strict equality operator ( === ). Second, object comparisons include a strict equality check of their prototypes.
* @example assert.deepStrictEqual(actual, expected[, message])
*/
def deepStrictEqual(actual: js.Any, expected: js.Any, message: String = js.native): Unit = js.native
def deepStrictEqual(actual: js.Any, expected: js.Any, message: String): Unit = js.native
def deepStrictEqual(actual: js.Any, expected: js.Any): Unit = js.native

def doesNotReject(asyncFn: js.Function | js.Promise[_],
error: js.RegExp | js.Function = js.native,
message: String = js.native
): Unit = js.native
def doesNotReject(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function, message: String): Unit =
js.native
def doesNotReject(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function): Unit = js.native
def doesNotReject(asyncFn: js.Function | js.Promise[_], message: String): Unit = js.native
def doesNotReject(asyncFn: js.Function | js.Promise[_]): Unit = js.native

/**
* Asserts that the function block does not throw an error. See assert.throws() for more details.
Expand All @@ -41,8 +44,10 @@ trait Assert extends js.Object {
* error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
* @example assert.doesNotThrow(block[, error][, message])
*/
def doesNotThrow(block: js.Function, error: js.RegExp | js.Function = js.native, message: String = js.native): Unit =
js.native
def doesNotThrow(block: js.Function, error: js.RegExp | js.Function, message: String): Unit = js.native
def doesNotThrow(block: js.Function, error: js.RegExp | js.Function): Unit = js.native
def doesNotThrow(block: js.Function, message: String): Unit = js.native
def doesNotThrow(block: js.Function): Unit = js.native

/**
* @see https://nodejs.org/api/assert.html#assert_assert_fail_message
Expand All @@ -67,26 +72,30 @@ trait Assert extends js.Object {
* Tests for deep strict inequality. Opposite of assert.deepStrictEqual().
* @example assert.notDeepStrictEqual(actual, expected[, message])
*/
def notDeepStrictEqual(actual: js.Any, expected: js.Any, message: String = js.native): Unit = js.native
def notDeepStrictEqual(actual: js.Any, expected: js.Any, message: String): Unit = js.native
def notDeepStrictEqual(actual: js.Any, expected: js.Any): Unit = js.native

/**
* Tests strict inequality as determined by the strict not equal operator ( !== ).
* @example assert.notStrictEqual(actual, expected[, message])
*/
def notStrictEqual(actual: js.Any, expected: js.Any, message: String = js.native): Unit = js.native
def notStrictEqual(actual: js.Any, expected: js.Any, message: String): Unit = js.native
def notStrictEqual(actual: js.Any, expected: js.Any): Unit = js.native

/**
* Tests if value is truthy. It is equivalent to assert.equal(!!value, true, message). If value is not truthy,
* an AssertionError is thrown with a message property set equal to the value of the message parameter. If the
* message parameter is undefined, a default error message is assigned.
*/
def ok(value: js.Any, message: String = js.native): Unit = js.native
def ok(value: js.Any, message: String): Unit = js.native
def ok(value: js.Any): Unit = js.native

/**
* Tests strict equality as determined by the strict equality operator ( === ).
* @example assert.strictEqual(actual, expected[, message])
*/
def strictEqual(actual: js.Any, expected: js.Any, message: String = js.native): Unit = js.native
def strictEqual(actual: js.Any, expected: js.Any, message: String): Unit = js.native
def strictEqual(actual: js.Any, expected: js.Any): Unit = js.native

/**
* If the values are not strictly equal, an AssertionError is thrown with a message property set equal to the value
Expand All @@ -99,9 +108,13 @@ trait Assert extends js.Object {
): Unit = js.native

def rejects(asyncFn: js.Function | js.Promise[_],
error: js.RegExp | js.Function | js.Object | Error = js.native,
message: String = js.native
error: js.RegExp | js.Function | js.Object | Error,
message: String
): Unit = js.native
def rejects(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function | js.Object | Error): Unit =
js.native
def rejects(asyncFn: js.Function | js.Promise[_], message: String): Unit = js.native
def rejects(asyncFn: js.Function | js.Promise[_]): Unit = js.native
}

/**
Expand Down
6 changes: 4 additions & 2 deletions app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Error.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import scala.scalajs.js.annotation.JSGlobal
*/
@js.native
@JSGlobal
class Error(message0: String = js.native) extends js.Object {
class Error(message0: String) extends js.Object {
def this() = this(???)

/**
* The `error.code` property is a string label that identifies the kind of error.
Expand Down Expand Up @@ -70,7 +71,8 @@ object Error extends js.Object {
* from an end user.
* @example Error.captureStackTrace(targetObject[, constructorOpt])
*/
def captureStackTrace(targetObject: js.Any, constructorOpt: js.Any = js.native): Unit = js.native
def captureStackTrace(targetObject: js.Any, constructorOpt: js.Any): Unit = js.native
def captureStackTrace(targetObject: js.Any): Unit = js.native
}

object ErrorCodes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ object Require extends Require

@js.native
trait RequireResolver extends js.Object {
def apply(request: String, options: ResolveOptions = js.native): js.Any = js.native
def apply(request: String, options: ResolveOptions): js.Any = js.native
def apply(request: String): js.Any = js.native

def paths(requiest: String): js.Array[String] = js.native
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import scala.scalajs.js.|
*/
@js.native
@JSImport("string_decoder", "StringDecoder")
class StringDecoder(encoding: String = js.native) extends IEventEmitter {
class StringDecoder(encoding: String) extends IEventEmitter {
def this() = this(???)

/**
* Returns any trailing bytes that were left in the buffer.
* @example decoder.end()
*/
def end(buffer: TypedArray[_, _] | DataView = js.native): String = js.native
def end(buffer: TypedArray[_, _] | DataView): String = js.native
def end(): String = js.native

/**
* Returns a decoded string.
Expand Down
Loading