question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin produces errors that tsc doesn't

See original GitHub issue

Formerly I was using rollup for typescript compilation via babel and the normal typescript compiler to emit declarations (tsc --emitDeclarationsOnly). Now I’d like to migrate to use your plugin. I have this configuration:

...
plugins: [
	...
	ts({
		tsconfig: resolvedOptions => ({
			emitDeclarationsOnly: true
		})
	})
]

However, with this setup I get some compilation errors from a library in node_modules. Both the tsc --emitDeclarationsOnly and the babel compilation are working without any compile errors.

For debugging purposes I was adding a console.log(resolvedOptions) and to my surprise it was invoked two times. The first time the options are looking OK but I have the feeling that it is not really compiling anything as it takes less then a second which is way faster then the normal tsc (normally my compilation takes 5 seconds or so).

The second time in the options some values are changed (outDir is set to “da39a3ee” and baseUrl is set to “.”) and on this second run it produces the compile error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wessbergcommented, Jul 1, 2020

Hi again,

Yes, this plugin will generate fundamentally different declarations than tsc does, given that one of the key features of this plugin is declaration bundling. That is one of the primary reasons I’ve found that users generally choose rollup-plugin-ts, given that it follows the folder structure of Rollup and even supports code splitting of the declaration files. Please read this section in the README for more details.

I will close this issue for now, but if you run into any other problems, feel free to create a new issue.

0reactions
manuel-maukycommented, Jun 16, 2020

Sorry for the late reply. We have solved our problem in the meantime with a different setup (using execute('tsc --emitDeclarationsOnly') with the “rollup-plugin-execute”) and it works for us.

I’ve tried the transpiler: "babel" option but still got some weird compilation errors. I had to use transpileOnly: true to rid of the errors. However, the resulting d.ts files are different from what tsc --emitDeclarationsOnly is producing. tsc does recreate the folder structure and puts each d.ts-file in the same sub-folder as it’s source-file while the plugin removes all folders and puts all files in directly in the dist/@types directory.

I’m not sure if I find the time to create a separate minimal repo. sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript compile has errors (using the tsc version ... - GitHub
Nice work on the starter kit! I add a npm script to run the typscript compiler in package.json like this: { "scripts": {...
Read more >
Typescript: Why doesn't visual studio code report the same ...
declare const State: TwineState;. If I delete the last character and then type tsc on the command line, it gives me this error:...
Read more >
@rollup/plugin-typescript - npm
This can fix plugin errors when parsing files outside the current working directory (process.cwd()). tsconfig. Type: String | Boolean Default: ...
Read more >
3 Options to Compile Typescript to JS: Rollup, TSC, Babel
The workaround on this is to add a tsc command with a modified tsconfig that only emits declaration files. The emitDeclarationTrue flag would ......
Read more >
TypeStrong/ts-loader - module - Gitter
index.d.ts" in its package.json. tsc is able to compile this project just fine, ... If for some reason it does not, you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found