@@ -529,8 +529,137 @@ extension type JSBoolean._(JSBooleanRepType _jsBoolean) implements JSAny {}
529529/// A JavaScript string.
530530extension type JSString ._(JSStringRepType _jsString) implements JSAny {}
531531
532+ @JS ('Symbol' )
533+ external JSSymbol _constructSymbol ([String ? description]);
534+
532535/// A JavaScript `Symbol` .
533- extension type JSSymbol ._(JSSymbolRepType _jsSymbol) implements JSAny {}
536+ extension type JSSymbol ._(JSSymbolRepType _jsSymbol) implements JSAny {
537+ // TODO(srujzs): See if this can be made `const` so it can be used in similar
538+ // situations to a Dart symbol literal.
539+ /// Creates a new, unique JavaScript `Symbol` .
540+ ///
541+ /// If [description] is provided, it's used for debugging but not to access
542+ /// the symbol itself.
543+ @Since ('3.11' )
544+ JSSymbol ([String ? description]) =>
545+ description == null ? _constructSymbol () : _constructSymbol (description);
546+
547+ /// Aearches for an existing symbol in a runtime-wide symbol registry with the
548+ /// given key and returns it if found.
549+ ///
550+ /// Otherwise, creates a new symbol with this key, adds it to the global
551+ /// registry, and returns it.
552+ @Since ('3.11' )
553+ @JS ('for' )
554+ external static JSSymbol forKey (String key);
555+
556+ /// `Symbol.asyncDispose` from the ECMAScript [explicit resource management]
557+ /// feature.
558+ ///
559+ /// [explicit resource management] : https://github.com/tc39/proposal-explicit-resource-management
560+ @Since ('3.11' )
561+ external static JSSymbol get asyncDispose;
562+
563+ /// See [`Symbol.asyncIterator`] .
564+ ///
565+ /// [`Symbol.asyncIterator`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator
566+ @Since ('3.11' )
567+ external static JSSymbol get asyncIterator;
568+
569+ /// `Symbol.dispose` from the ECMAScript [explicit resource management]
570+ /// feature.
571+ ///
572+ /// [explicit resource management] : https://github.com/tc39/proposal-explicit-resource-management
573+ @Since ('3.11' )
574+ external static JSSymbol get dispose;
575+
576+ /// See [`Symbol.hasInstance`] .
577+ ///
578+ /// [`Symbol.hasInstance`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance
579+ @Since ('3.11' )
580+ external static JSSymbol get hasInstance;
581+
582+ /// See [`Symbol.isConcatSpreadable`] .
583+ ///
584+ /// [`Symbol.isConcatSpreadable`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable
585+ @Since ('3.11' )
586+ external static JSSymbol get isConcatSpreadable;
587+
588+ /// See [`Symbol.iterator`] .
589+ ///
590+ /// [`Symbol.iterator`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator
591+ @Since ('3.11' )
592+ external static JSSymbol get iterator;
593+
594+ /// See [`Symbol.match`] .
595+ ///
596+ /// [`Symbol.match`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match
597+ @Since ('3.11' )
598+ external static JSSymbol get match;
599+
600+ /// See [`Symbol.matchAll`] .
601+ ///
602+ /// [`Symbol.matchAll`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/matchAll
603+ @Since ('3.11' )
604+ external static JSSymbol get matchAll;
605+
606+ /// See [`Symbol.replace`] .
607+ ///
608+ /// [`Symbol.replace`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace
609+ @Since ('3.11' )
610+ external static JSSymbol get replace;
611+
612+ /// See [`Symbol.search`] .
613+ ///
614+ /// [`Symbol.search`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search
615+ @Since ('3.11' )
616+ external static JSSymbol get search;
617+
618+ /// See [`Symbol.species`] .
619+ ///
620+ /// [`Symbol.species`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species
621+ @Since ('3.11' )
622+ external static JSSymbol get species;
623+
624+ /// See [`Symbol.split`] .
625+ ///
626+ /// [`Symbol.split`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split
627+ @Since ('3.11' )
628+ external static JSSymbol get split;
629+
630+ /// See [`Symbol.toPrimitive`] .
631+ ///
632+ /// [`Symbol.toPrimitive`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive
633+ @Since ('3.11' )
634+ external static JSSymbol get toPrimitive;
635+
636+ /// See [`Symbol.toStringTag`] .
637+ ///
638+ /// [`Symbol.toStringTag`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
639+ @Since ('3.11' )
640+ external static JSSymbol get toStringTag;
641+
642+ /// See [`Symbol.unscopables`] .
643+ ///
644+ /// [`Symbol.unscopables`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables
645+ @Since ('3.11' )
646+ external static JSSymbol get unscopables;
647+
648+ @Since ('3.11' )
649+ @JS ('keyFor' )
650+ external static String ? _keyFor (JSSymbol symbol);
651+
652+ /// Returns the shared symbol key from the global symbol registry for this
653+ /// symbol (as registered with [forKey] ), if this symbol was created with
654+ /// [Symbol.forKey] .
655+ @Since ('3.11' )
656+ String get key => _keyFor (this );
657+
658+ /// A string containing the description of the symbol, as passed to [new
659+ /// Symbol].
660+ @Since ('3.11' )
661+ external String get description;
662+ }
534663
535664/// A JavaScript `BigInt` .
536665extension type JSBigInt ._(JSBigIntRepType _jsBigInt) implements JSAny {}
0 commit comments