Skip to content

Commit 3e8d635

Browse files
vchimevmanoldonev
authored andcommitted
feat(platform-declarations): generate typings from iOS 13.0 SDK (#7817)
* feat(platform-declarations): generate typings from iOS 13.0 SDK * fix(platform-declarations): typings generation script Delete Material Components typings from `tns-platform-declarations`, they are part of `tns-core-modules` package. * refactor(platform-declarations): workaround a TypeScript error Error: ``` tns-platform-declarations/ios/objc-x86_64/objc!OSLog.d.ts(178,15): error TS2417: Class static side 'typeof OSLogEnumerator' incorrectly extends base class static side 'typeof NSEnumerator'. Types of property 'alloc' are incompatible. Type '() => OSLogEnumerator' is not assignable to type '<ObjectType>() => NSEnumerator<ObjectType>'. Type 'OSLogEnumerator' is not assignable to type 'NSEnumerator<ObjectType>'. Types of property 'allObjects' are incompatible. Type 'NSArray<NSObject>' is not assignable to type 'NSArray<ObjectType>'. Type 'NSObject' is not assignable to type 'ObjectType'. 'NSObject' is assignable to the constraint of type 'ObjectType', but 'ObjectType' could be instantiated with a different subtype of constraint '{}'. ``` References: microsoft/TypeScript#17575 https://stackoverflow.com/questions/52518125/workaround-for-accessing-class-type-arguments-in-static-method-in-typescript * docs(platform-declarations): note a manual step on generating typings * chore(platform-declarations): exclude ios-typings-prj from transpilation * refactor(platform-declarations): delete references to MDC types ``` ios/objc-x86_64/objc!QuartzCore.d.ts:676:36 - error TS2304: Cannot find name 'MDCAnimationTimingFunction'. 676 static mdc_functionWithType(type: MDCAnimationTimingFunction): CAMediaTimingFunction; ios/objc-x86_64/objc!UIKit.d.ts:7717:54 - error TS2304: Cannot find name 'MDCFontTextStyle'. 7717 static mdc_preferredFontForMaterialTextStyle(style: MDCFontTextStyle): UIFont; ios/objc-x86_64/objc!UIKit.d.ts:7719:53 - error TS2304: Cannot find name 'MDCFontTextStyle'. 7719 static mdc_standardFontForMaterialTextStyle(style: MDCFontTextStyle): UIFont; ios/objc-x86_64/objc!UIKit.d.ts:7771:63 - error TS2304: Cannot find name 'MDCFontTextStyle'. 7771 mdc_fontSizedForMaterialTextStyleScaledForDynamicType(style: MDCFontTextStyle, scaled: boolean): UIFont; ios/objc-x86_64/objc!UIKit.d.ts:7794:64 - error TS2304: Cannot find name 'MDCFontTextStyle'. 7794 static mdc_preferredFontDescriptorForMaterialTextStyle(style: MDCFontTextStyle): UIFontDescriptor; ios/objc-x86_64/objc!UIKit.d.ts:7796:63 - error TS2304: Cannot find name 'MDCFontTextStyle'. 7796 static mdc_standardFontDescriptorForMaterialTextStyle(style: MDCFontTextStyle): UIFontDescriptor; ```
1 parent dfcbe6c commit 3e8d635

109 files changed

Lines changed: 26761 additions & 4871 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Folders
22
dist
33
hooks
4+
ios-typings-prj
45
libs
56
node_modules
67
package

tns-platform-declarations/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
*.tgz
2+
ios-typings-prj
23
package
34
test.ts
45
test.js
56
test.js.map
67
tsconfig.json
7-
typings-gen.sh
8+
typings-gen.sh

tns-platform-declarations/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ The `.d.ts` files for iOS are generated using iOS Runtime's metadata generator.
4646
./typings-gen.sh rc [<path-to-medatadata-generator-binary>]
4747
```
4848
Where `rc` can be an NPM tag/version of `tns-ios` that will be used for generating the typings. If the metadata generator to be used has not been released in NPM, you can optionally specify its path as a 2nd argument.
49+
50+
> Note: Apply [this](https://github.com/NativeScript/NativeScript/commit/45b4b061e470c19cdc582f220ee86fd3169269a0) commit on hand, due to a TypeScript error.
51+
52+
> The script expressly deletes the `objc!MaterialComponents.d.ts` file which [distributes](https://github.com/NativeScript/NativeScript/pull/7480) along with the `tns-core-modules` package to avoid plugins clashes.
53+
54+
> However, the metadata generator for iOS includes metadata and typings for the whole SDK and all native libraries in use, including `MaterialComponents`. Therefore, there are typings which reference types from `objc!MaterialComponents.d.ts` file and fail on transpilation.
55+
56+
> Currently, remove these by hand to avoid transpilation errors. A proposed Solution is to specify which entries to be generated metadata for and be accessible from JavaScript. These are the feature requests for [Android](https://github.com/NativeScript/android-runtime/issues/1485) and [iOS](https://github.com/NativeScript/ios-runtime/issues/1209)

tns-platform-declarations/ios/ios.d.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/// <reference path="objc-x86_64/objc!AssetsLibrary.d.ts" />
1212
/// <reference path="objc-x86_64/objc!AudioToolbox.d.ts" />
1313
/// <reference path="objc-x86_64/objc!AuthenticationServices.d.ts" />
14+
/// <reference path="objc-x86_64/objc!BackgroundTasks.d.ts" />
1415
/// <reference path="objc-x86_64/objc!BusinessChat.d.ts" />
1516
/// <reference path="objc-x86_64/objc!CFNetwork.d.ts" />
1617
/// <reference path="objc-x86_64/objc!CallKit.d.ts" />
@@ -21,12 +22,13 @@
2122
/// <reference path="objc-x86_64/objc!Compression.d.ts" />
2223
/// <reference path="objc-x86_64/objc!Contacts.d.ts" />
2324
/// <reference path="objc-x86_64/objc!ContactsUI.d.ts" />
24-
/// <reference path="objc-x86_64/objc!CoreAudio.d.ts" />
2525
/// <reference path="objc-x86_64/objc!CoreAudioKit.d.ts" />
26+
/// <reference path="objc-x86_64/objc!CoreAudioTypes.d.ts" />
2627
/// <reference path="objc-x86_64/objc!CoreBluetooth.d.ts" />
2728
/// <reference path="objc-x86_64/objc!CoreData.d.ts" />
2829
/// <reference path="objc-x86_64/objc!CoreFoundation.d.ts" />
2930
/// <reference path="objc-x86_64/objc!CoreGraphics.d.ts" />
31+
/// <reference path="objc-x86_64/objc!CoreHaptics.d.ts" />
3032
/// <reference path="objc-x86_64/objc!CoreImage.d.ts" />
3133
/// <reference path="objc-x86_64/objc!CoreLocation.d.ts" />
3234
/// <reference path="objc-x86_64/objc!CoreMIDI.d.ts" />
@@ -39,6 +41,7 @@
3941
/// <reference path="objc-x86_64/objc!CoreTelephony.d.ts" />
4042
/// <reference path="objc-x86_64/objc!CoreText.d.ts" />
4143
/// <reference path="objc-x86_64/objc!CoreVideo.d.ts" />
44+
/// <reference path="objc-x86_64/objc!CryptoTokenKit.d.ts" />
4245
/// <reference path="objc-x86_64/objc!Darwin.d.ts" />
4346
/// <reference path="objc-x86_64/objc!DeviceCheck.d.ts" />
4447
/// <reference path="objc-x86_64/objc!Dispatch.d.ts" />
@@ -61,11 +64,14 @@
6164
/// <reference path="objc-x86_64/objc!IOSurface.d.ts" />
6265
/// <reference path="objc-x86_64/objc!IdentityLookup.d.ts" />
6366
/// <reference path="objc-x86_64/objc!IdentityLookupUI.d.ts" />
67+
/// <reference path="objc-x86_64/objc!ImageCaptureCore.d.ts" />
6468
/// <reference path="objc-x86_64/objc!ImageIO.d.ts" />
6569
/// <reference path="objc-x86_64/objc!Intents.d.ts" />
6670
/// <reference path="objc-x86_64/objc!IntentsUI.d.ts" />
6771
/// <reference path="objc-x86_64/objc!JavaScriptCore.d.ts" />
72+
/// <reference path="objc-x86_64/objc!LinkPresentation.d.ts" />
6873
/// <reference path="objc-x86_64/objc!LocalAuthentication.d.ts" />
74+
/// <reference path="objc-x86_64/objc!MDFInternationalization.d.ts" />
6975
/// <reference path="objc-x86_64/objc!MachO.d.ts" />
7076
/// <reference path="objc-x86_64/objc!MapKit.d.ts" />
7177
/// <reference path="objc-x86_64/objc!MediaAccessibility.d.ts" />
@@ -76,6 +82,7 @@
7682
/// <reference path="objc-x86_64/objc!Metal.d.ts" />
7783
/// <reference path="objc-x86_64/objc!MetalKit.d.ts" />
7884
/// <reference path="objc-x86_64/objc!MetalPerformanceShaders.d.ts" />
85+
/// <reference path="objc-x86_64/objc!MetricKit.d.ts" />
7986
/// <reference path="objc-x86_64/objc!ModelIO.d.ts" />
8087
/// <reference path="objc-x86_64/objc!MultipeerConnectivity.d.ts" />
8188
/// <reference path="objc-x86_64/objc!NativeScriptEmbedder.d.ts" />
@@ -84,22 +91,27 @@
8491
/// <reference path="objc-x86_64/objc!NetworkExtension.d.ts" />
8592
/// <reference path="objc-x86_64/objc!NewsstandKit.d.ts" />
8693
/// <reference path="objc-x86_64/objc!NotificationCenter.d.ts" />
94+
/// <reference path="objc-x86_64/objc!OSLog.d.ts" />
8795
/// <reference path="objc-x86_64/objc!ObjectiveC.d.ts" />
8896
/// <reference path="objc-x86_64/objc!OpenAL.d.ts" />
8997
/// <reference path="objc-x86_64/objc!OpenGLES.d.ts" />
9098
/// <reference path="objc-x86_64/objc!PDFKit.d.ts" />
9199
/// <reference path="objc-x86_64/objc!PassKit.d.ts" />
100+
/// <reference path="objc-x86_64/objc!PencilKit.d.ts" />
92101
/// <reference path="objc-x86_64/objc!Photos.d.ts" />
93102
/// <reference path="objc-x86_64/objc!PhotosUI.d.ts" />
103+
/// <reference path="objc-x86_64/objc!Pods_iostypingsprj.d.ts" />
94104
/// <reference path="objc-x86_64/objc!PushKit.d.ts" />
95105
/// <reference path="objc-x86_64/objc!QuartzCore.d.ts" />
96106
/// <reference path="objc-x86_64/objc!QuickLook.d.ts" />
107+
/// <reference path="objc-x86_64/objc!QuickLookThumbnailing.d.ts" />
97108
/// <reference path="objc-x86_64/objc!ReplayKit.d.ts" />
98109
/// <reference path="objc-x86_64/objc!SQLite3.d.ts" />
99110
/// <reference path="objc-x86_64/objc!SafariServices.d.ts" />
100111
/// <reference path="objc-x86_64/objc!SceneKit.d.ts" />
101112
/// <reference path="objc-x86_64/objc!Security.d.ts" />
102113
/// <reference path="objc-x86_64/objc!Social.d.ts" />
114+
/// <reference path="objc-x86_64/objc!SoundAnalysis.d.ts" />
103115
/// <reference path="objc-x86_64/objc!Speech.d.ts" />
104116
/// <reference path="objc-x86_64/objc!SpriteKit.d.ts" />
105117
/// <reference path="objc-x86_64/objc!StoreKit.d.ts" />
@@ -112,16 +124,15 @@
112124
/// <reference path="objc-x86_64/objc!VideoSubscriberAccount.d.ts" />
113125
/// <reference path="objc-x86_64/objc!VideoToolbox.d.ts" />
114126
/// <reference path="objc-x86_64/objc!Vision.d.ts" />
127+
/// <reference path="objc-x86_64/objc!VisionKit.d.ts" />
115128
/// <reference path="objc-x86_64/objc!WatchConnectivity.d.ts" />
116-
/// <reference path="objc-x86_64/objc!WatchKit.d.ts" />
117129
/// <reference path="objc-x86_64/objc!WebKit.d.ts" />
118130
/// <reference path="objc-x86_64/objc!_Builtin_intrinsics.d.ts" />
119131
/// <reference path="objc-x86_64/objc!asl.d.ts" />
120132
/// <reference path="objc-x86_64/objc!dnssd.d.ts" />
121133
/// <reference path="objc-x86_64/objc!iAd.d.ts" />
122134
/// <reference path="objc-x86_64/objc!libkern.d.ts" />
123135
/// <reference path="objc-x86_64/objc!libxml2.d.ts" />
124-
/// <reference path="objc-x86_64/objc!libxslt.d.ts" />
125136
/// <reference path="objc-x86_64/objc!os.d.ts" />
126137
/// <reference path="objc-x86_64/objc!os_object.d.ts" />
127138
/// <reference path="objc-x86_64/objc!simd.d.ts" />

0 commit comments

Comments
 (0)