TS6053 File not found when import tsd.d.ts from bower distributed package
I'm having a issue while trying to tsd link (tsd@next) a bower package and tsd.d.ts
First I've a package built with grunt-ts and grunt-tsd
// Gruntfile.js
ts: {
dev: {
options: {
sourceMap: false
},
reference: 'dist/ts/FormManager.d.ts',
src: 'src/ts/**/*.ts'
}
},
tsd: {
options: {
config: 'tsd.json'
},
install: {
options: {
command: 'reinstall'
}
}
}
So FormManager.d.ts has the following content (made by grunt-ts):
//grunt-start
/// <reference path="../../src/ts/AutoSave/FormAutoSave.ts" />
/// <reference path="../../src/ts/AutoSave/TemporalStorage.ts" />
/// <reference path="../../src/ts/Manager/FieldManager.ts" />
/// <reference path="../../src/ts/Manager/FormManager.ts" />
/// <reference path="../../src/ts/global/Window.ts" />
//grunt-end
each of these *.ts files have this line at the begin.
/// <reference path="../../../typings/tsd.d.ts" />
After distribute this package and execute tsd link I've the folliowing ./typings/tsd.d.ts
/// <reference path="../bower_components/form-manager/dist/ts/FormManager.d.ts" />
Finally when I execute tsc I've the following errors.
../../../bower_components/form-manager/src/ts/AutoSave/FormAutoSave.ts(1,1): error TS6053: File '../../../bower_components/form-manager/typings/tsd.d.ts' not found. ../../../bower_components/form-manager/src/ts/AutoSave/TemporalStorage.ts(1,1): error TS6053: File '../../../bower_components/form-manager/typings/tsd.d.ts' not found. ../../../bower_components/form-manager/src/ts/Manager/FieldManager.ts(1,1): error TS6053: File '../../../bower_components/form-manager/typings/tsd.d.ts' not found. ../../../bower_components/form-manager/src/ts/Manager/FormManager.ts(1,1): error TS6053: File '../../../bower_components/form-manager/typings/tsd.d.ts' not found.
Any suggestion about how to proper distribute definitions without to have distribute vendor definitions as well?
Additionally if I opt for include the vendor typings I end with duplicated definitions because the bower package and the parent project both use JQuery
../bower_components/form-manager/typings/jquery/jquery.d.ts(29,5): error TS2300: Duplicate identifier 'accepts'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(33,5): error TS2300: Duplicate identifier 'async'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(41,5): error TS2300: Duplicate identifier 'cache'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(49,5): error TS2300: Duplicate identifier 'contents'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(55,5): error TS2300: Duplicate identifier 'contentType'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(59,5): error TS2300: Duplicate identifier 'context'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(63,5): error TS2300: Duplicate identifier 'converters'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(67,5): error TS2300: Duplicate identifier 'crossDomain'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(71,5): error TS2300: Duplicate identifier 'data'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(79,5): error TS2300: Duplicate identifier 'dataType'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(87,5): error TS2300: Duplicate identifier 'global'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(91,5): error TS2300: Duplicate identifier 'headers'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(95,5): error TS2300: Duplicate identifier 'ifModified'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(99,5): error TS2300: Duplicate identifier 'isLocal'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(103,5): error TS2300: Duplicate identifier 'jsonp'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(107,5): error TS2300: Duplicate identifier 'jsonpCallback'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(111,5): error TS2300: Duplicate identifier 'mimeType'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(115,5): error TS2300: Duplicate identifier 'password'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(119,5): error TS2300: Duplicate identifier 'processData'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(123,5): error TS2300: Duplicate identifier 'scriptCharset'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(127,5): error TS2300: Duplicate identifier 'statusCode'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(135,5): error TS2300: Duplicate identifier 'timeout'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(139,5): error TS2300: Duplicate identifier 'traditional'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(143,5): error TS2300: Duplicate identifier 'type'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(147,5): error TS2300: Duplicate identifier 'url'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(151,5): error TS2300: Duplicate identifier 'username'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(155,5): error TS2300: Duplicate identifier 'xhr'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(159,5): error TS2300: Duplicate identifier 'xhrFields'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(183,5): error TS2300: Duplicate identifier 'responseJSON'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(325,2): error TS2300: Duplicate identifier 'always'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(332,2): error TS2300: Duplicate identifier 'done'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(339,2): error TS2300: Duplicate identifier 'fail'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(523,5): error TS2300: Duplicate identifier 'data'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(524,5): error TS2300: Duplicate identifier 'delegateTarget'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(528,5): error TS2300: Duplicate identifier 'namespace'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(529,5): error TS2300: Duplicate identifier 'originalEvent'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(531,5): error TS2300: Duplicate identifier 'relatedTarget'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(532,5): error TS2300: Duplicate identifier 'result'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(535,5): error TS2300: Duplicate identifier 'pageX'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(536,5): error TS2300: Duplicate identifier 'pageY'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(537,5): error TS2300: Duplicate identifier 'which'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(538,5): error TS2300: Duplicate identifier 'metaKey'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(542,5): error TS2300: Duplicate identifier 'altKey'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(543,5): error TS2300: Duplicate identifier 'ctrlKey'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(544,5): error TS2300: Duplicate identifier 'metaKey'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(545,5): error TS2300: Duplicate identifier 'shiftKey'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(549,5): error TS2300: Duplicate identifier 'button'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(550,5): error TS2300: Duplicate identifier 'clientX'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(551,5): error TS2300: Duplicate identifier 'clientY'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(552,5): error TS2300: Duplicate identifier 'offsetX'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(553,5): error TS2300: Duplicate identifier 'offsetY'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(554,5): error TS2300: Duplicate identifier 'pageX'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(555,5): error TS2300: Duplicate identifier 'pageY'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(556,5): error TS2300: Duplicate identifier 'screenX'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(557,5): error TS2300: Duplicate identifier 'screenY'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(561,5): error TS2300: Duplicate identifier 'char'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(562,5): error TS2300: Duplicate identifier 'charCode'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(563,5): error TS2300: Duplicate identifier 'key'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(564,5): error TS2300: Duplicate identifier 'keyCode'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(575,5): error TS2300: Duplicate identifier 'ajax'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(576,5): error TS2300: Duplicate identifier 'boxModel'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(577,5): error TS2300: Duplicate identifier 'changeBubbles'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(578,5): error TS2300: Duplicate identifier 'checkClone'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(579,5): error TS2300: Duplicate identifier 'checkOn'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(580,5): error TS2300: Duplicate identifier 'cors'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(581,5): error TS2300: Duplicate identifier 'cssFloat'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(582,5): error TS2300: Duplicate identifier 'hrefNormalized'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(583,5): error TS2300: Duplicate identifier 'htmlSerialize'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(584,5): error TS2300: Duplicate identifier 'leadingWhitespace'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(585,5): error TS2300: Duplicate identifier 'noCloneChecked'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(586,5): error TS2300: Duplicate identifier 'noCloneEvent'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(587,5): error TS2300: Duplicate identifier 'opacity'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(588,5): error TS2300: Duplicate identifier 'optDisabled'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(589,5): error TS2300: Duplicate identifier 'optSelected'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(591,5): error TS2300: Duplicate identifier 'style'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(592,5): error TS2300: Duplicate identifier 'submitBubbles'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(593,5): error TS2300: Duplicate identifier 'tbody'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(628,5): error TS2300: Duplicate identifier 'left'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(629,5): error TS2300: Duplicate identifier 'top'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(636,5): error TS2300: Duplicate identifier 'duration'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(640,5): error TS2300: Duplicate identifier 'easing'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(644,5): error TS2300: Duplicate identifier 'complete'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(648,5): error TS2300: Duplicate identifier 'step'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(652,5): error TS2300: Duplicate identifier 'progress'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(656,5): error TS2300: Duplicate identifier 'start'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(660,5): error TS2300: Duplicate identifier 'done'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(664,5): error TS2300: Duplicate identifier 'fail'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(668,5): error TS2300: Duplicate identifier 'always'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(672,5): error TS2300: Duplicate identifier 'queue'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(676,5): error TS2300: Duplicate identifier 'specialEasing'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(712,5): error TS2300: Duplicate identifier 'ajaxSettings'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(781,5): error TS2300: Duplicate identifier 'param'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(918,5): error TS2300: Duplicate identifier 'cssHooks'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(919,5): error TS2300: Duplicate identifier 'cssNumber'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(1000,5): error TS2300: Duplicate identifier 'fx'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(1032,5): error TS2300: Duplicate identifier 'Event'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(1041,5): error TS2300: Duplicate identifier 'expr'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(1042,5): error TS2300: Duplicate identifier 'fn'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(1044,5): error TS2300: Duplicate identifier 'isReady'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(1047,5): error TS2300: Duplicate identifier 'support'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(2989,5): error TS2300: Duplicate identifier 'context'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(2991,5): error TS2300: Duplicate identifier 'jquery'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(3543,5): error TS2300: Duplicate identifier 'length'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(3548,5): error TS2300: Duplicate identifier 'selector'. ../bower_components/form-manager/typings/jquery/jquery.d.ts(3549,5): error TS2374: Duplicate string index signature. ../bower_components/form-manager/typings/jquery/jquery.d.ts(3550,5): error TS2375: Duplicate number index signature. ../bower_components/form-manager/typings/jquery/jquery.d.ts(3923,5): error TS2308: A module cannot have more than one export assignment. jquery/jquery.d.ts(3923,5): error TS2308: A module cannot have more than one export assignment.
Vendor definitions are a bit of a complicated problem. Most of it has to do with the current way the compiler resolves types for modules.
At this point there is only one 'type namespace': so if different definition files are referenced which all define modules with the same name ('jquery') then the compiler will throw this 'Duplicate identifier'. (contrast this to how node.js resolves modules, where every package can have its isolated sub dependencies)
This gets very messy if packages start to bundle their definition files, because like you experience many web modules would use the JQuery definitions (and maybe even re-export types), which means the compiler sees all the bundled jquery definitions.
This (and similar issues) is on the map of the TypeScript team, for example:
- https://github.com/Microsoft/TypeScript/issues/247
- https://github.com/Microsoft/TypeScript/issues/575
At this point TSD can't do much about it, but part of the experimental nature of tsd link is discovering these kind of issues.
At this moment I see two issues
One related to vendor files distribution and another one about duplicate definitions loading.
The first one should be fixed from the side doing recursive installation of vendors looking for the presence of tsd.json
The second one is a issue of tsc and it's out of the tsd scope
One related to vendor files distribution [.....] doing recursive installation of vendors looking for the presence of tsd.json
Could you expand on this?
If we would scan all linked types and recognize vendor files, what then? If we'd unifiy references then I see a possible issue of compatibility between versions of vendored defs.
Also note currently bundled typings we tsd link are expected to be self contained. This means they might be one file (dts-bundle on a small package) or possibly <reference> other files in their package, like installed typings.
This means they might be one file (dts-bundle on a small package) or possibly
other files in their package, like installed typings.
I was expecting this actually. When I release my module, I included the typings directory with it and my definition file still points to that directory when it's installed. The bower.json points to only my definition file. Yet, I still get the error TS2300: Duplicate identifier when I do tsd link... Is that expected?
Edit Nevermind, user error. This seems to work properly.
@mtraynham what was your user error? I'm getting error TS2300 Duplicate identifier when using tsd link as both my root project and it's dependencies depend on some of the same typings (lodash, angular etc).
I can't find a good way to handle these duplicates without just using my bower packages without their definition files like I would in javascript, which sucks.
@xiphiaz Well looking back, it's not entirely user error as by "working properly", yeah you can't include jquery.d.ts twice. Since bower has a flat structure and soon to be npm v.3, this will be less of a problem when modules start distributing their own .d.ts files.
The work around, at the moment, is don't put DefinitelyTyped typings in the bower file. Only put your own generated d.ts file if the module created one. So if you are passing your own d.ts files around, this workaround does have the caveat that you'll be linking definition files that don't have their own dependencies resolved, so you'll have to include a tsd.json and run tsd install prior to linking.
Easiest way to do that, is take the dependent module's tsd.json files and merge them (likely by hand) to satisfy those definitions (without duplication).
In the past, it was sort of convention to bundle or checkin your definition files... I just run tsd install during npm preinstall and tsd link during npm postinstall. The same can be done with bower, if that's where you are storing your typescript definition references.
Thanks @mtraynham, I had two bootstrap dependency in bower.json and package.json. With the removal of the dependency the package.json solved the problem.