Skip to content

Commit

Permalink
Merge branch 'TS34'
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Apr 1, 2019
2 parents 93fdb27 + 9cfb521 commit 8ee55ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 13 additions & 2 deletions Signum.React/Scripts/Operations/ContextualOperations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../Operations'
import { DropdownItem } from "../Components/DropdownItem";
import { UncontrolledTooltip } from "../Components/Tooltip";
import { IconProp } from "@fortawesome/fontawesome-svg-core";

export function getConstructFromManyContextualItems(ctx: ContextualItemsContext<Entity>): Promise<MenuItemBlock | undefined> | undefined {
if (ctx.lites.length == 0)
Expand Down Expand Up @@ -195,7 +196,7 @@ export namespace MenuItemConstructor { //To allow monkey patching
simplifyName(coc.operationInfo.niceName);

const color = coc.settings && coc.settings.color || coc.entityOperationSettings && coc.entityOperationSettings.color || Defaults.getColor(coc.operationInfo);
const icon = coc.settings && coc.settings.icon || coc.entityOperationSettings && coc.entityOperationSettings.icon;
const icon = coalesceIcon(coc.settings && coc.settings.icon, coc.entityOperationSettings && coc.entityOperationSettings.icon);
const iconColor = coc.settings && coc.settings.iconColor || coc.entityOperationSettings && coc.entityOperationSettings.iconColor;

const disabled = !!coc.canExecute;
Expand All @@ -215,7 +216,7 @@ export namespace MenuItemConstructor { //To allow monkey patching
data-operation={coc.operationInfo.key}>
{icon ? <FontAwesomeIcon icon={icon} className="icon" color={iconColor} fixedWidth /> :
color ? <span className={classes("icon", "empty-icon", "btn-" + color)}></span> : undefined}
{(icon || color) && " "}
{(icon != null || color != null) && " "}
{text}
</DropdownItem>,
coc.canExecute ? <UncontrolledTooltip placement="right" target={() => innerRef!}>{coc.canExecute}</UncontrolledTooltip> : undefined
Expand Down Expand Up @@ -273,5 +274,15 @@ export function defaultContextualClick(coc: ContextualOperationContext<any>, ...
}
}).done();



}


export function coalesceIcon(icon: IconProp | undefined, icon2: IconProp | undefined): IconProp | undefined{ //Till the error is fixed
if (icon != null)
return icon;

return icon2;
}

13 changes: 3 additions & 10 deletions Signum.React/Signum.React.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TypeScriptToolsVersion>3.3</TypeScriptToolsVersion>
<TypeScriptToolsVersion>3.4</TypeScriptToolsVersion>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
Expand All @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.3.1">
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.4.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down Expand Up @@ -42,12 +42,5 @@
<TypeScriptCompile Include="**\*.ts" />
</ItemGroup>

<ItemGroup>
<Content Remove="package.json" />
</ItemGroup>

<ItemGroup>
<None Include="package.json" />
</ItemGroup>

</Project>

1 comment on commit 8ee55ca

@olmobrutall
Copy link
Collaborator Author

@olmobrutall olmobrutall commented on 8ee55ca Apr 2, 2019

Choose a reason for hiding this comment

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

Update to Typescript 3.4

TypeScript 3.4 has been just released https://devblogs.microsoft.com/typescript/announcing-typescript-3-4/ so I've merged the TS34 branch into master.

The sexiest improvement is incremental flag, that could make compilation faster. Unfortunately doesn't work when noEmit is enabled yet, so it doesn't work for us. Issue in TS repo here: microsoft/TypeScript#30661

The transition was pretty straightforward except for font-awesome typings generating error TS2590: Build:Expression produces a union type that is too complex to represent. on certain cases, but using coalesceIcon helper method did the trick. Issue here FortAwesome/Font-Awesome#14774

Remember to:

  • Install the VS extension for interllisense.
  • Update TypeScriptToolsVersion tag and nuget in all your React projects.
  • Update packages.json

Please sign in to comment.