angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

Importing interfaces from @uirouter/angularjs do not match type definitions and are broken (1.0.6) #3514

Closed mtraynham closed 4 years ago

mtraynham commented 7 years ago

This issue tracker is for Bug Reports and Feature Requests only. Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a:

My version of UI-Router is: 1.0.6 (1.0.5 works correctly)

Bug Report

Current Behavior:

import {StateService} from '@uirouter/angularjs'; returns an undefined object.

Expected Behavior:

import {StateService} from '@uirouter/angularjs'; returns the StateService

I believe this a bug with how the release/ui-router-angular.js is generated and the issue is exposed by this particular commit.

With 1.0.5, the package.json main path pointed to lib/index.js. Within that (compiled) file, there is a re-export of all @uirouter/core objects.

/**
 * Main entry point for angular 1.x build
 * @module ng1
 */ /** */
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./services"));
__export(require("./statebuilders/views"));
__export(require("./stateProvider"));
__export(require("./urlRouterProvider"));
require("./injectables");
require("./directives/stateDirectives");
require("./stateFilters");
require("./directives/viewDirective");
require("./viewScroll");
exports.default = "ui.router";
var core = require("@uirouter/core");
exports.core = core;
__export(require("@uirouter/core"));
//# sourceMappingURL=index.js.map

The important line here being:

__export(require("@uirouter/core"));

Now with 1.0.6, the package.json main path points to release/ui-router-angularjs.js. This file contains no such line that would have a similar re-export.

/**
 * Main entry point for angular 1.x build
 * @module ng1
 */ /** */
var index = "ui.router";

exports['default'] = index;
exports.core = _uirouter_core;
exports.watchDigests = watchDigests;
exports.getLocals = getLocals;
exports.getNg1ViewConfigFactory = getNg1ViewConfigFactory;
exports.ng1ViewsBuilder = ng1ViewsBuilder;
exports.Ng1ViewConfig = Ng1ViewConfig;
exports.StateProvider = StateProvider;
exports.UrlRouterProvider = UrlRouterProvider;

Object.defineProperty(exports, '__esModule', { value: true });

})));

Link to Plunker that reproduces the issue:

http://bit.ly/UIR-Plunk

itanex commented 6 years ago

I created a simple ASP.NET CORE 2.0 MVC application and started plugging in an NG1 app. This is the first time I encountered the new updates and cannot seem to get the type definitions to resolve. I have been through the closed linked issue attempting what I found there. I searched SO for an Q&A but found nothing.

Typescript just throws the standard TS2307. Cannot find module '@uirouter/core'

Please let me know what other details would help.

itanex commented 6 years ago

UPDATE 2018/02/05

I have updated my project with expectation that this might have been resolved.

Test 1 UIRouter 1.0.14 Typescript 2.6.2

Test 2 UIRouter 1.0.14 Typescript 2.7.1

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.