1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

feat: add new esnext types (#11627)

This commit is contained in:
Kitson Kelly 2021-08-10 18:33:08 +10:00 committed by GitHub
parent 453dfaa960
commit 465cf9a6fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 1 deletions

View file

@ -130,7 +130,9 @@ fn create_compiler_snapshot(
"es2021.string",
"es2021.weakref",
"esnext",
"esnext.error",
"esnext.intl",
"esnext.object",
"esnext.promise",
"esnext.string",
"esnext.weakref",

View file

@ -20,5 +20,7 @@ and limitations under the License.
/// <reference lib="es2021" />
/// <reference lib="esnext.array" />
/// <reference lib="esnext.error" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.object" />
/// <reference lib="esnext.string" />

16
cli/dts/lib.esnext.error.d.ts vendored Normal file
View file

@ -0,0 +1,16 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
/// <reference no-default-lib="true"/>
interface Error {
cause?: any;
}
interface ErrorInit {
cause?: any;
}
interface ErrorConstructor {
new (message?: string, init?: ErrorInit): Error;
(message?: string, init?: ErrorInit): Error;
}

12
cli/dts/lib.esnext.object.d.ts vendored Normal file
View file

@ -0,0 +1,12 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
/// <reference no-default-lib="true"/>
interface ObjectConstructor {
/**
* Determines whether an object has a property with the specified name.
* @param o The target object.
* @param v A property name.
*/
hasOwn(o: object, v: PropertyKey): boolean;
}

View file

@ -1,5 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import { assertEquals, unitTest } from "./test_util.ts";
import { assert, assertEquals, unitTest } from "./test_util.ts";
// TODO(@kitsonk) remove when we are no longer patching TypeScript to have
// these types available.
@ -10,3 +10,14 @@ unitTest(function typeCheckingEsNextArrayString() {
const b = ["a", "b", "c", "d", "e", "f"];
assertEquals(b.at(-1), "f");
});
unitTest(function objectHasOwn() {
const a = { a: 1 };
assert(Object.hasOwn(a, "a"));
assert(!Object.hasOwn(a, "b"));
});
unitTest(function errorCause() {
const e = new Error("test", { cause: "something" });
assertEquals(e.cause, "something");
});

View file

@ -37080,6 +37080,8 @@ var ts;
["es2021.promise", "lib.es2021.promise.d.ts"],
["es2021.string", "lib.es2021.string.d.ts"],
["es2021.weakref", "lib.es2021.weakref.d.ts"],
["esnext.object", "lib.esnext.object.d.ts"],
["esnext.error", "lib.esnext.error.d.ts"],
["esnext.array", "lib.esnext.array.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],