Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Gents produces invalid TS when using aliases for string or numbers #499

Open
joelpoloney opened this issue Apr 19, 2017 · 1 comment
Open
Labels

Comments

@joelpoloney
Copy link

joelpoloney commented Apr 19, 2017

Ran into this problem today. The following code:

/**
 * @typedef {string}
 */
Foo;

/**
 * @typedef {string}
 */
Bar;

/**
 * @private {!Object<Foo, Bar>}
 */
var fooBar = {};

becomes:

type Foo = string;
type Bar = string;
let fooBar: {[key: Foo]: Bar} = {};

which then gives you a TS compiler error: An index signature parameter type must be 'string' or 'number'.

Ideally we know not to use Foo as the type for the key, and use string instead.

Context on why this isn't supported is here: microsoft/TypeScript#7374.

@mprobst
Copy link
Contributor

mprobst commented Apr 19, 2017 via email

@rkirov rkirov added the gents label May 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants