File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
Plugins/BridgeJS/Sources/TS2Swift/JavaScript Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -747,8 +747,8 @@ export class TypeProcessor {
747747 * @private
748748 */
749749 visitStructuredType ( type , diagnosticNode , members ) {
750- const symbol = type . getSymbol ( ) ?? type . aliasSymbol ;
751- const name = symbol ?. name ?? this . checker . typeToString ( type ) ;
750+ const symbol = type . aliasSymbol ?? type . getSymbol ( ) ;
751+ const name = type . aliasSymbol ?. name ?? symbol ?. name ?? this . checker . typeToString ( type ) ;
752752 if ( ! name ) return ;
753753 if ( this . emittedStructuredTypeNames . has ( name ) ) return ;
754754 this . emittedStructuredTypeNames . add ( name ) ;
@@ -760,7 +760,7 @@ export class TypeProcessor {
760760 if ( jsNameArg ) args . push ( jsNameArg ) ;
761761 const annotation = this . renderMacroAnnotation ( "JSClass" , args ) ;
762762 const typeName = this . renderIdentifier ( swiftName ) ;
763- const docNode = symbol ?. getDeclarations ( ) ?. [ 0 ] ?? diagnosticNode ;
763+ const docNode = type . aliasSymbol ?. getDeclarations ( ) ?. [ 0 ] ?? symbol ?. getDeclarations ( ) ?. [ 0 ] ?? diagnosticNode ;
764764 if ( docNode ) {
765765 this . emitDocComment ( docNode , { indent : "" } ) ;
766766 }
Original file line number Diff line number Diff line change @@ -426,6 +426,25 @@ exports[`ts2swift > snapshots Swift output for TypeAlias.d.ts > TypeAlias 1`] =
426426"
427427`;
428428
429+ exports[`ts2swift > snapshots Swift output for TypeAliasObject.d.ts > TypeAliasObject 1`] = `
430+ "// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit,
431+ // DO NOT EDIT.
432+ //
433+ // To update this file, just rebuild your project or run
434+ // \`swift package bridge-js\`.
435+
436+ @_spi(Experimental) @_spi(BridgeJS) import JavaScriptKit
437+
438+ @JSFunction func console() throws(JSException) -> Console
439+
440+ /// Console from the environment.
441+ @JSClass struct Console {
442+ // / Log a message.
443+ @JSFunction func log (_ message : String ) throws (JSException ) - > Void
444+ }
445+ "
446+ `;
447+
429448exports[`ts2swift > snapshots Swift output for TypeScriptClass.d.ts > TypeScriptClass 1`] = `
430449"// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit,
431450// DO NOT EDIT.
Original file line number Diff line number Diff line change 1+ /**
2+ * Console from the environment.
3+ */
4+ export type Console = {
5+ /**
6+ * Log a message.
7+ */
8+ log ( message : string ) : void ;
9+ } ;
10+
11+ export function console ( ) : Console ;
You can’t perform that action at this time.
0 commit comments