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.

Ambient declarations not working due to import/export

See original GitHub issue

The import and export statements in danger.d.ts are preventing the danger DSL from being available in the global scope:

danger-ambient-declarations

This is a known issue in Typescript *.d.ts files (ambient declarations): https://github.com/microsoft/TypeScript/issues/28097

A potential solution per this comment is to wrap global declarations in a declare global { } block.

EDIT: This appears to do the trick based on a quick test. Here’s a minimum set of changes: https://github.com/carmanchris31/danger-ambient-declarations-repro/commit/e897e351bb253505075606acc9fde51fc429776e?w=1

Where should one look in the code in order to attempt addressing this?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
fbarthocommented, Apr 2, 2020

We could provide a file that plugin authors could directly reference that would hook up that global scope?

Danger-plugin-interface.d.ts (not sure if that would work?)

1reaction
airtonixcommented, Mar 2, 2022

You should never need to include those helpers in user-land Dangerfile

That said, I think re-exporting the types from an index file is a cool idea 👍🏻

wat?

without import { DangerDSLType} from 'danger';

image

with import { DangerDSLType} from 'danger';

image

it’s really strange that you’re injecting stuff into global space in the first place to be brutually honest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ambient module declaration with import - typescript
In an attempt to fix this I imported the proper type from a known library into the typings. d. ts this supplies the...
Read more >
TypeScript Language Service having problems with ambient ...
a. In there use ambient interface without import, interface will be colored red, on hover the error will read "TS2304: Cannot find name...
Read more >
Documentation - Modules - TypeScript
Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export keyword. StringValidator.ts. ts. export ......
Read more >
TypeScript errors and how to fix them
To fix the problem you have to update the reference path to point to another ... TypeScript does not allow statements in such...
Read more >
TypeScript Cheatsheet, Common Errors, and More
If using an ambient declaration file only for types interface Window ... implicit issues, as well as prevent errors related to mismatched ...
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