mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00

* 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: https://github.com/Microsoft/TypeScript/issues/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; ```
57 lines
1.7 KiB
Bash
Executable File
57 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e -o pipefail
|
|
|
|
IOS_RUNTIME_VERSION=$1
|
|
METADATA_GENERATOR_PATH=$2
|
|
|
|
if [ -z "$1" ]
|
|
then
|
|
printf "Usage:\n"
|
|
printf "./typings-gen.sh <tns-ios-npm-version> [<objc-metadata-generator-binary>]\n"
|
|
printf "\n\nExample:\n"
|
|
printf "./typings-gen.sh rc ~/work/ios-runtime/cmake-build/metadataGenerator/bin/objc-metadata-generator\n\n"
|
|
exit -1
|
|
fi
|
|
|
|
if [ -n "$METADATA_GENERATOR_PATH" -a ! -f "$METADATA_GENERATOR_PATH" ]
|
|
then
|
|
echo "error: Specified metadata generator binary \"$METADATA_GENERATOR_PATH\" does not exist!"
|
|
exit -2
|
|
fi
|
|
|
|
echo "Creating typings project with tns-ios@$IOS_RUNTIME_VERSION..."
|
|
rm -rf ios-typings-prj
|
|
tns create --js ios-typings-prj
|
|
tns platform add ios@$IOS_RUNTIME_VERSION --path ios-typings-prj/
|
|
|
|
if [ -n "$METADATA_GENERATOR_PATH" ]
|
|
then
|
|
echo "Replacing metadata generator binary with: $METADATA_GENERATOR_PATH"
|
|
rm ios-typings-prj/platforms/ios/internal/metadata-generator/bin/objc-metadata-generator
|
|
cp $METADATA_GENERATOR_PATH ios-typings-prj/platforms/ios/internal/metadata-generator/bin/objc-metadata-generator
|
|
|
|
fi
|
|
|
|
echo "Building project and generating typings..."
|
|
TNS_TYPESCRIPT_DECLARATIONS_PATH=$(pwd)/ios-typings-prj/typings tns build ios --debug --path ios-typings-prj/
|
|
|
|
echo "Deleting old ios typings (ios/objc-x86_64)..."
|
|
rm ios/objc-x86_64/*
|
|
|
|
echo "Deleting Material Components typings..."
|
|
rm ios-typings-prj/typings/x86_64/objc\!MaterialComponents.d.ts
|
|
|
|
echo "Moving generated typings to ios/objc-x86_64..."
|
|
mv ios-typings-prj/typings/x86_64/* ios/objc-x86_64/
|
|
|
|
echo "Emitting (ios/ios.d.ts)..."
|
|
pushd ios
|
|
|
|
echo '/// <reference path="runtime.d.ts" />' > ios.d.ts
|
|
|
|
for i in `ls objc-x86_64/*.d.ts`; do
|
|
echo "/// <reference path=\"$i\" />" >> ios.d.ts
|
|
done
|
|
|
|
popd
|