Skip to content

Commit c10c783

Browse files
committed
Fix unique symbols
1 parent 516bde8 commit c10c783

File tree

1 file changed

+21
-9
lines changed
  • packages/core-js-types/src/base/pure/proposals

1 file changed

+21
-9
lines changed

packages/core-js-types/src/base/pure/proposals/symbol.d.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,32 @@
3232
// License: https://github.com/microsoft/TypeScript/blob/v5.9.3/LICENSE.txt
3333

3434
declare namespace CoreJS {
35-
const CoreJSFallbackSymbol: unique symbol;
36-
type CoreJSFallbackSymbolType = typeof CoreJSFallbackSymbol;
37-
type GetNativeWithFallback<T, K extends PropertyKey> = K extends keyof T ? T[K] : CoreJSFallbackSymbolType;
35+
const CoreJSDisposeSymbol: unique symbol;
36+
const CoreJSAsyncDisposeSymbol: unique symbol;
37+
const CoreJSAsyncIteratorSymbol: unique symbol;
38+
const CoreJSCustomMatcherSymbol: unique symbol;
39+
const CoreJSMetadataSymbol: unique symbol;
40+
const CoreJSMatchAllSymbol: unique symbol;
41+
42+
type CoreJSDisposeSymbolType = typeof CoreJSDisposeSymbol;
43+
type CoreJSAsyncDisposeSymbolType = typeof CoreJSAsyncDisposeSymbol;
44+
type CoreJSAsyncIteratorSymbolType = typeof CoreJSAsyncIteratorSymbol;
45+
type CoreJSCustomMatcherSymbolType = typeof CoreJSCustomMatcherSymbol;
46+
type CoreJSMetadataSymbolType = typeof CoreJSMetadataSymbol;
47+
type CoreJSMatchAllSymbolType = typeof CoreJSMatchAllSymbol;
48+
49+
type GetNativeWithFallback<T, K extends PropertyKey, Fallback> = K extends keyof T ? T[K] : Fallback;
3850

3951
export interface CoreJSSymbolConstructor extends SymbolConstructor {
4052
/**
4153
* A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
4254
*/
43-
readonly dispose: GetNativeWithFallback<SymbolConstructor, 'dispose'>;
55+
readonly dispose: GetNativeWithFallback<SymbolConstructor, 'dispose', CoreJSDisposeSymbolType>;
4456

4557
/**
4658
* A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
4759
*/
48-
readonly asyncDispose: GetNativeWithFallback<SymbolConstructor, 'asyncDispose'>;
60+
readonly asyncDispose: GetNativeWithFallback<SymbolConstructor, 'asyncDispose', CoreJSAsyncDisposeSymbolType>;
4961

5062
/**
5163
* Determines whether the given value is a registered symbol.
@@ -63,13 +75,13 @@ declare namespace CoreJS {
6375
* A method that returns the default async iterator for an object. Called by the semantics of
6476
* the for-await-of statement.
6577
*/
66-
readonly asyncIterator: GetNativeWithFallback<SymbolConstructor, 'asyncIterator'>;
78+
readonly asyncIterator: GetNativeWithFallback<SymbolConstructor, 'asyncIterator', CoreJSAsyncIteratorSymbolType>;
6779

68-
readonly customMatcher: GetNativeWithFallback<SymbolConstructor, 'customMatcher'>;
80+
readonly customMatcher: GetNativeWithFallback<SymbolConstructor, 'customMatcher', CoreJSCustomMatcherSymbolType>;
6981

70-
readonly metadata: GetNativeWithFallback<SymbolConstructor, 'metadata'>;
82+
readonly metadata: GetNativeWithFallback<SymbolConstructor, 'metadata', CoreJSMetadataSymbolType>;
7183

72-
readonly matchAll: GetNativeWithFallback<SymbolConstructor, 'matchAll'>;
84+
readonly matchAll: GetNativeWithFallback<SymbolConstructor, 'matchAll', CoreJSMatchAllSymbolType>;
7385
}
7486

7587
export interface CoreJSSymbol extends Symbol {

0 commit comments

Comments
 (0)