You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 own index.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 in DefinitelyTyped.
In the fancybox/index.d.ts file I have the following
importheapfrom'../@types/heap/index';heap.identify(opts.email);// unique identifierheap.addUserProperties({'Name': opts.name});// other props
This works great as far as vscodes intellisense goes, but tscc fails with
TSCC: Module name ts.webcore.$001stypes.heap.index$.d$.ts was not provided as a closure compilation source
I tried adding "heap": "heap" to my tscc externs, but that didn't help. I also played around a ton with setting the closure compiler typeRoots, 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
goog.module('ts.webcore.$001stypes.heap')/** Generated by TSCC */exports=heap;
This led me to try changing the tscc spec extern to "ts/webcore/@types/heap": "heap", but that only renames the gluing file to ts.webcore.$001stypes.heap.js, and I'm guessing that because the name isn't ts.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:
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 import heap from 'heap';, which also satisfies the intellisense, but doesn't change the error, and the gluing file turns into this
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!
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 (.d.ts file do not emit .js files), hence the error.
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.
Then tscc will create gluing modules and goog.require it whenever a file tries to import the ./ts/webcore/@types/heap/index file. Files in different directory may use different module name to refer to the same module, because module resolution algorithm is in act here.
When a relative path (those starting with ./ or ../) is used as a key in "external" value in spec files, it is resolved from the spec file's location itself, not the current working directory.
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: