-
Notifications
You must be signed in to change notification settings - Fork 11
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
How to include custom definition files? #506
Comments
I also tried the comment here about setting a path in the tsconfig.json to point directly to the custom type microsoft/TypeScript#22217 (comment) "paths": {
"heap": ["ts/webcore/@types/heap"],
} And then changing my import to goog.module('heap')
/** Generated by TSCC */
exports = heap; which looks like that attempt is going in the opposite direction perhaps. Side note, but we've been using this for all of our projects since I first started making issues here (lol), and we absolutely love your tool! |
In the statement import heap from '../@types/heap/index'; the imported module name is a relative path, and it refers to a file located there. When tscc collects source files to feed to closure compiler, it looks for the above path and founds nothing ( In order to have such modules to be considered as external, you have to provide the module's path to the spec file, like below. {
"external": {
"./ts/webcore/@types/heap/index": "heap"
}
} Then tscc will create gluing modules and When a relative path (those starting with |
In the README, I have mentioned about declaring relative path as an external module, but now I found that it is not very prominent. I guess it'd be nice to elaborate it more with some examples. |
We use a service called "heap", that provides just an interface in their documentation for typescript users.
In our project we have a custom
@types
folder where I've been putting my ownindex.d.ts
files, but so far they've all been just adding things to jQuery, and only for things that already don't have definition files inDefinitelyTyped
.In the
fancybox/index.d.ts
file I have the followingand this just kind of magically works with my
tscc.spec.json
fileand my my
tsconfig.json
My
heap/index.d.ts
file looks likeand using like this
This works great as far as vscodes intellisense goes, but tscc fails with
I tried adding
"heap": "heap"
to my tscc externs, but that didn't help. I also played around a ton with setting the closure compilertypeRoots
, but nothing seemed to change the behavior, and I also stumbled upon this comment that makes me see that that wasn't the correct approach anyway microsoft/TypeScript#12222 (comment).I also see in the debug output it's re-writing the import as the following, where I'm sure the error is coming from.
The gluing file being generated is named "heap.js" which contains
This led me to try changing the tscc spec extern to
"ts/webcore/@types/heap": "heap"
, but that only renames the gluing file tots.webcore.$001stypes.heap.js
, and I'm guessing that because the name isn'tts.webcore.$001stypes.heap.index$.d$.ts'
is where the problem arises. I couldn't figure out how to right the extern in the tscc spec file to get the names to match.Am I doing something wrong? Is there a way to reference custom type definition files?
The text was updated successfully, but these errors were encountered: