quipper / i18n-dts

A d.ts file generator for i18n-js.
Apache License 2.0
48 stars 6 forks source link

Improve: change return type to string literal #7

Closed hotchemi closed 5 years ago

hotchemi commented 5 years ago

Overview

This PR improves traceability between string resource and type definition file.

For now, you can figure out which key exists in string resource but can't discover a relation between key and value.

It means you may have to move around resource json file and view every time you want to use new string resource..to solve the problem this PR changes return type to string literal, now you can leverage IDE power!

screen shot 2018-11-27 at 21 55 13

Generated file would be like below.

declare module "react-native-i18n" {
    var fallbacks: boolean;
    var translations: {
        [keys: string]: any;
    };
-    function t(key: "title"): string;
+    function t(key: "title"): 'Example';
}