@@ -42,6 +42,14 @@ public final class SwiftToSkeleton {
4242 self . typeDeclResolver . addSourceFile (
4343 """
4444 @JSClass struct JSPromise {}
45+ @JSClass struct JSInt8Array {}
46+ @JSClass struct JSUint8Array {}
47+ @JSClass struct JSInt16Array {}
48+ @JSClass struct JSUint16Array {}
49+ @JSClass struct JSInt32Array {}
50+ @JSClass struct JSUint32Array {}
51+ @JSClass struct JSFloat32Array {}
52+ @JSClass struct JSFloat64Array {}
4553 """
4654 )
4755 }
@@ -128,11 +136,35 @@ public final class SwiftToSkeleton {
128136 )
129137 }
130138
139+ private static let jsTypedArrayTypealiasNames : [ String : String ] = [
140+ " Int8 " : " JSInt8Array " ,
141+ " UInt8 " : " JSUint8Array " ,
142+ " Int16 " : " JSInt16Array " ,
143+ " UInt16 " : " JSUint16Array " ,
144+ " Int32 " : " JSInt32Array " ,
145+ " UInt32 " : " JSUint32Array " ,
146+ " Float " : " JSFloat32Array " ,
147+ " Float32 " : " JSFloat32Array " ,
148+ " Double " : " JSFloat64Array " ,
149+ " Float64 " : " JSFloat64Array " ,
150+ ]
151+
131152 func lookupType ( for type : TypeSyntax , errors : inout [ DiagnosticError ] ) -> BridgeType ? {
132153 if let attributedType = type . as ( AttributedTypeSyntax . self ) {
133154 return lookupType ( for : attributedType . baseType , errors : & errors )
134155 }
135156
157+ // JSTypedArray<T>
158+ if let identifierType = type . as ( IdentifierTypeSyntax . self ) ,
159+ identifierType . name . text == " JSTypedArray " ,
160+ let genericArgs = identifierType . genericArgumentClause ? . arguments ,
161+ genericArgs . count == 1 ,
162+ let elementName = genericArgs . first ? . argument . as ( IdentifierTypeSyntax . self ) ? . name . text ,
163+ let typealiasName = Self . jsTypedArrayTypealiasNames [ elementName ]
164+ {
165+ return . jsObject ( typealiasName )
166+ }
167+
136168 if let identifierType = type . as ( IdentifierTypeSyntax . self ) ,
137169 identifierType . name . text == " JSTypedClosure " ,
138170 let genericArgs = identifierType . genericArgumentClause ? . arguments ,
0 commit comments