Skip to content

TypeScript 2.5 compatibility #4794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tns-core-modules/ui/image/image-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ImageSource, fromAsset, fromNativeSource, fromUrl } from "../../image-s
import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils";

export * from "../core/view";
export { ImageSource, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };
export { ImageSource, ImageAsset, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };

export abstract class ImageBase extends View implements ImageDefinition {
public imageSource: ImageSource;
Expand All @@ -24,7 +24,7 @@ export abstract class ImageBase extends View implements ImageDefinition {
/**
* @internal
*/
public _createImageSourceFromSrc(value: string | ImageSource): void {
public _createImageSourceFromSrc(value: string | ImageSource | ImageAsset): void {
const originalValue = value;
const sync = this.loadMode === "sync";
if (typeof value === "string" || value instanceof String) {
Expand Down
4 changes: 2 additions & 2 deletions tns-core-modules/ui/image/image.android.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ImageSource, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, Color,
ImageSource, ImageAsset, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, Color,
isDataURI, isFileOrResourcePath, RESOURCE_PREFIX
} from "./image-common";
import { knownFolders } from "../../file-system";
Expand Down Expand Up @@ -75,7 +75,7 @@ export class Image extends ImageBase {
this.nativeViewProtected.setImageMatrix(new android.graphics.Matrix());
}

public _createImageSourceFromSrc(value: string | ImageSource) {
public _createImageSourceFromSrc(value: string | ImageSource | ImageAsset) {
const imageView = this.nativeViewProtected;
if (!imageView) {
return;
Expand Down
20 changes: 10 additions & 10 deletions tns-core-modules/ui/styling/style-properties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Types
import {
import {
Transformation,
TransformationValue,
TransformFunctionsInfo,
Expand Down Expand Up @@ -456,13 +456,13 @@ const TRANSFORMATIONS = Object.freeze([
const STYLE_TRANSFORMATION_MAP = Object.freeze({
"scale": value => ({ property: "scale", value }),
"scale3d": value => ({ property: "scale", value }),
"scaleX": ({x}) => ({ property: "scale", value: { x, y: IDENTITY_TRANSFORMATION.scale.y } }),
"scaleY": ({y}) => ({ property: "scale", value: { y, x: IDENTITY_TRANSFORMATION.scale.x } }),
"scaleX": ({ x }) => ({ property: "scale", value: { x, y: IDENTITY_TRANSFORMATION.scale.y } }),
"scaleY": ({ y }) => ({ property: "scale", value: { y, x: IDENTITY_TRANSFORMATION.scale.x } }),

"translate": value => ({ property: "translate", value }),
"translate3d": value => ({ property: "translate", value }),
"translateX": ({x}) => ({ property: "translate", value: { x, y: IDENTITY_TRANSFORMATION.translate.y } }),
"translateY": ({y}) => ({ property: "translate", value: { y, x: IDENTITY_TRANSFORMATION.translate.x } }),
"translateX": ({ x }) => ({ property: "translate", value: { x, y: IDENTITY_TRANSFORMATION.translate.y } }),
"translateY": ({ y }) => ({ property: "translate", value: { y, x: IDENTITY_TRANSFORMATION.translate.x } }),

"rotate": value => ({ property: "rotate", value }),
});
Expand Down Expand Up @@ -501,12 +501,12 @@ export function transformConverter(text: string): TransformFunctionsInfo {
return fullTransformations;
}

const affineMatrix = transformations
const affineMatrix = transformations
.map(getTransformMatrix)
.reduce(multiplyAffine2d)
const cssMatrix = matrixArrayToCssMatrix(affineMatrix)
const cssMatrix = matrixArrayToCssMatrix(affineMatrix)

return decompose2DTransformMatrix(cssMatrix);
return decompose2DTransformMatrix(cssMatrix);
}

// using general regex and manually checking the matched
Expand All @@ -528,8 +528,8 @@ function parseTransformString(text: string): Transformation[] {
return matches;
}

function normalizeTransformation({ property, value }: Transformation) {
return STYLE_TRANSFORMATION_MAP[property](value);
function normalizeTransformation({ property, value }: Transformation): Transformation {
return <any>STYLE_TRANSFORMATION_MAP[property](value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is that cast needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript cannot assure that all callbacks from STYLE_TRANSFORMATION_MAP actually return Transformation

}

function convertTransformValue(property: string, stringValue: string)
Expand Down