Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26276] TypeScript: Add dict types for create factory functions

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTooling
Labelsn/a
ReporterJan Vennemann
AssigneeJan Vennemann
Created2018-08-08T11:41:50.000+0000
Updated2019-11-19T11:59:29.000+0000

Description

Improve creation dict typings for create factory functions. This is currently set to any but we could create a dictionary of available properties with [Distributive conditional types](http://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types)

Comments

  1. Sergey Volkov 2019-11-08

    These definitions from [typescript-alloy-app](https://github.com/appcelerator/titanium-boilerplates/blob/master/templates/typescript-alloy-app/app/globals.d.ts) could be moved to the main @types/titanium
       type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
       type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
       type Dictionary<T> = Partial<NonFunctionProperties<T>>;
       
    -Or shorter version:- -type Dictionary = Partial>>- I was wrong, short version is incorrect.
  2. Sergey Volkov 2019-11-19

    https://github.com/appcelerator/docs-devkit/pull/8

JSON Source