-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Assertion functions don't work with wildcard imports #35004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
To reproduce this issue, you have to use namespace imports |
I seem to recall that a lot of cleverness was required to support tracking these assertion signatures through property access without performance regressions, so this isn’t super surprising... But since |
I believe this issue is preventing shipping assert guards in
I'm going to look further into this, especially since This is the PR if people want to take a look: DefinitelyTyped/DefinitelyTyped#42786 |
@RyanCavanaugh Is there any plan to fix this? |
@dfilatov eventually, yes, or if someone wants to send a PR, that'd be great |
Here is a similar case which affects the module-ified TS compiler: // @strict: true
// @filename: src/core/_namespaces/ts.ts
import * as Debug from "../debug";
export { Debug };
// @filename: src/core/debug.ts
export declare function assert(expression: unknown): asserts expression;
// @filename: src/core/foo.ts
import * as ts from "./_namespaces/ts";
import { Debug } from "./_namespaces/ts";
ts.Debug.assert(true);
Debug.assert(true);
// @filename: src/other/_namespaces/ts.ts
export * from "../../core/_namespaces/ts"
// @filename: src/other/bar.ts
import * as ts from "./_namespaces/ts";
import { Debug } from "./_namespaces/ts";
ts.Debug.assert(true);
Debug.assert(true);
|
This turned out to be really simple; will send a PR for it soon. |
TypeScript Version: 3.7.2
Search Terms:
assert function import export
Code
Expected behavior:
Everything works as expected
Actual behavior:
Error: Assertions require every name in the call target to be declared with an explicit type annotation.
If I rewrite test.ts with:
then everything compiles without any error
The text was updated successfully, but these errors were encountered: