Need warn about ts files (not dts) in compilation from node_modules
See original GitHub issueI would like to include the typings for https://github.com/Lusito/typed-signals in my DTS bundle, however the extraction fails with “Error: Cannot find symbol for node: emitCollecting”.
app.ts:
import {Signal} from "typed-signals";
export const signal: Signal<(argument) => void> = undefined;
package.json:
{
"name": "dts-bundle-generator-bugreport",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "npx tsc",
"typings": "npx dts-bundle-generator -o app.d.ts app.ts"
},
"dependencies": {
"typed-signals": "^1.0.2"
},
"devDependencies": {
"dts-bundle-generator": "^1.6.1",
"typescript": "^3.1.3"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"declaration": true,
"lib": ["es2015", "dom"]
}
}
Run:
npm install
npm run typings
Output:
Error: Cannot find symbol for node: emitCollecting
The method looks like this (see https://github.com/Lusito/typed-signals/blob/master/src/Signal.ts):
export class Signal<CB extends Function> {
// ...
protected emitCollecting<RT>(collector: Collector<CB, RT>, args: any) {
// ...
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
How to get rid of the warning .ts file is part of the TypeScript ...
WARNING in src/war/angular/src/app/app-routing.module.ts is part of the TypeScript compilation but it's unused. Add only entry points to the ' ...
Read more >How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Learn how to use Rollup as a smaller, more efficient alternative to webpack and Browserify to bundle JavaScript files in this step-by-step tutorial...
Read more >Migrating to Typescript: Write a declaration file for a third-party ...
As of TypeScript 2.2, there is a straight-forward way to add a declaration file for a popular npm module. All you need to...
Read more >Configuring Vitest
ts when it is present to match with the plugins and setup as your Vite app. If you want to have a different...
Read more >ts-node-dev - npm.io
The good thing is that ts-node-dev watches used tsconfig.json file, and will reinitialize compilation on its change, but you have to restart the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m back after looong time 😃
Hm, it’s a little bit unexpected for me. I believe it speeds up builds, but it confuses.
Yeah, I need. There is a lot of issues caused by that - https://github.com/timocov/dts-bundle-generator/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3Adetect-import-path-problem
I believe in this case you need to have resolver/scheduler which will make a build plan and detect which packages can be built in parallel.
I just dig into
and it seems that there is no way to get dts file for module from
node_modules
directory. The compiler doesn’t provide a way to generate declaration file for any source file (liketranspile
ortranspileModule
to get JS output).If you ignore that warning, does it work correct for you or you get some errors?
/cc @aleclarson
I can’t imagine a case where it’s ok, even for monorepos, because it would be better to have compiled
.d.ts
files instead of.ts
ones to avoid unnecessary compilation of source files which wouldn’t generate an output.Also, I believe that in case of monorepo you need to compile dependencies first and generate
.d.ts
files for them (it’ll reduce a building time as well, because parsing.d.ts
is easier than parsing and compiling.ts
file).Also that warning is about
.ts
files in node_modules folder, which (I believe) shouldn’t be even exist in common case of using npm/yarn (because a packages should provide declaration files, not source files as declaration ones).Not actually. Resolving symlinks are for the TypeScript compiler. After the compiler creates the program,
dts-bundle-generator
uses files it provides to work with them, and there is real paths, not import/require’s ones. For nowdts-bundle-generator
treats file as external by its path (so, iftsc
resolves an import to original file located in the same folder -dts-bundle-generator
will treat it as local one, not external; but if no symlinks resolving happened, then a file’s path will containnode_modules
path and the tool will treat it as external).How to detect that some module is external one? It looks like we have a path of the file only for that.