mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
feat: add new esnext types (#11627)
This commit is contained in:
parent
453dfaa960
commit
465cf9a6fe
6 changed files with 46 additions and 1 deletions
|
@ -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",
|
||||
|
|
2
cli/dts/lib.esnext.d.ts
vendored
2
cli/dts/lib.esnext.d.ts
vendored
|
@ -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
16
cli/dts/lib.esnext.error.d.ts
vendored
Normal 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
12
cli/dts/lib.esnext.object.d.ts
vendored
Normal 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;
|
||||
}
|
|
@ -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");
|
||||
});
|
||||
|
|
2
cli/tsc/00_typescript.js
vendored
2
cli/tsc/00_typescript.js
vendored
|
@ -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"],
|
||||
|
|
Loading…
Reference in a new issue