Plugin producing `*.d.ts` with in-line imports
See original GitHub issueWhat happens and why it is wrong
rollup-plugin-typescript2
is generating *.d.ts
file that is not valid TypeScript:
export declare function deferredAction<T extends StdOut>(saga: Saga<T, Action>, io: T): (action: DeferredAction) => IterableIterator<SetContextEffect<any> | etc..| import("../node_modules/redux-saga/effects").Effect[]>;
Notice the import("../node_modules/redux-saga/effects").Effect[]
that is trying to be used as a type parameter.
I’ve run tsc
directly, which behaves as expected (aside from dumping all the built files in the wrong spot).
This is for a library I’m working on, so the source (and the branch) is here
Environment
Versions
- typescript:
^2.9.1
- rollup:
^0.59.4
- rollup-plugin-typescript2:
^0.14.0
rollup.config.js
import typescript from 'rollup-plugin-typescript2'
const baseConfig = {
plugins: [ typescript() ],
input: 'src/index.ts',
external: [
'redux',
'redux-saga',
'redux-saga/effects'
]
}
const esConfig = Object.assign(
{},
baseConfig,
{
output: {
exports: 'named',
file: 'dist/es/index.js',
format: 'es'
}
}
)
const cjsConfig = Object.assign(
{},
baseConfig,
{
output: {
exports: 'named',
file: 'dist/cjs/index.js',
format: 'cjs'
}
}
)
export default [
cjsConfig,
esConfig
]
tsconfig.json
{
"exclude": [
"**/*.test.ts",
"node_modules"
],
"include": [ "src/**/*.ts" ],
"compilerOptions": {
"baseUrl": "./",
"declaration": true,
"downlevelIteration": true,
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"noUnusedParameters": true,
"removeComments": false,
"sourceMap": true,
"strict": true,
"target": "es5",
"lib": [
"dom",
"esnext"
],
"paths": {
"@/*": ["src/*"]
},
"plugins": [
{ "name": "tslint-language-service"}
]
}
}
package.json
{
"scripts": { "build": "rm -rf dist && npx rollup -c" }
}
plugin output with verbosity 3
I don’t see anything that looks relevant, though I can amend this.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Somtimes generating inline imports for d.ts files instead of ...
Problem statement: The d.ts file generated during my compile step looks like this: export declare const authContentFeatureReducer ...
Read more >Import class in definition file (*d.ts) - typescript - Stack Overflow
d.ts files are treated as an ambient module declarations only if they ... are not declaring a module, you can import inline at...
Read more >Cannot find module" when using inline webpack loaders with ...
Trying to use a webpack raw-loader for an HTML file inline resulted in an error: TS2307: Cannot find module. Here's how to fix...
Read more >TSConfig Reference - Docs on every TSConfig option
Allows importing modules with a '.json' extension, which is a common practice in node projects. This includes generating a type for the import...
Read more >Features | Vite
You can also use the query option to provide custom queries to imports for other plugins to consume. ts const modules = import.meta ......
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
@ezolenko took your advice and ran
./node_modules/.bin/tsc
, which does reproduce the problem—hmm, something got weird in TypeScript2.9.1
— the globaltsc
is2.8.1
.I factored out those typings, as they were kind of borked, but still weird.
And check that you use the same typescript version when running tsc as when using rollup or webpack plugins (global vs local install)