Skip to content
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

Recursive type definitions #2011

Closed
jart opened this issue Sep 13, 2016 · 2 comments
Closed

Recursive type definitions #2011

jart opened this issue Sep 13, 2016 · 2 comments

Comments

@jart
Copy link
Contributor

jart commented Sep 13, 2016

In TypeScript, I can do the following

interface RecursiveArray<T> extends Array<T|RecursiveArray<T>> {}

But in Closure, I can't do this:

/**
 * @typedef {!Array<T|RecursiveArray<T>>}
 * @template T
 */
var RecursiveArray;
@dimvar
Copy link
Contributor

dimvar commented Sep 13, 2016

You can define recursive structural types with @record. Typedefs can only be used to define an alias for an existing type, not to define a new type.

@dimvar dimvar closed this as completed Sep 13, 2016
@jart
Copy link
Contributor Author

jart commented Sep 13, 2016

Amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants