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

Too difficult to augment values which do not export their type #12074

Closed
DanielRosenwasser opened this issue Nov 6, 2016 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Nov 6, 2016

Let's take this file (react-router/lib/Route.d.ts):

import * as React from 'react';
import Router from './Router';
import { Location } from 'history';

declare const self: self.Route;
type self = self.Route;

declare namespace self {
    interface RouteProps extends React.Props<Route> {
        path?: Router.RoutePattern;
        // ...
    }
    interface Route extends React.ComponentClass<RouteProps> {}
    interface RouteElement extends React.ReactElement<RouteProps> {}
}

export default self;

Let's say that I wanted to write a module augmentation for this.

There is no way (that I can think of) to reopen the namespace or any of the interfaces.

  1. Local namespace/interface merging is not allowed with imports.
  2. There is no way I can reopen a default export in a module augmentation.

As a result, I have to rewrite react-router so that I can make it augmentable because the original author did not think far ahead enough to support it.

@DanielRosenwasser
Copy link
Member Author

I should actually take back what I said in part - it is not so much that the author didn't think far enough ahead to support augmentations, but rather, that the module is available using a default export. The author wanted to export all of the types through the default export as well, but as mentioned above, there is no way to reopen default exports.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 9, 2017

looks like a duplicate of #14080

@mhegazy mhegazy added the Duplicate An existing issue was already created label Mar 9, 2017
@mhegazy mhegazy closed this as completed Apr 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants