-
Notifications
You must be signed in to change notification settings - Fork 13.3k
In JS, assertions imported via commonjs have bogus error #38379
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Code
// @filename: declares.d.ts
// this is the declaration for 'assert' from @types/node
export function art(value: any, message?: string | Error): asserts value;
// @filename: test.js
const { art } = require('./declares')
let x = 1
art(x)Expected behavior:
No error.
Actual behavior:
Error: "Assertions require every name in the call target to be declared with an explicit type annotation."
There is no error when using ES imports:
// @filename: test2.js
import { art } from './declares'
let x = 1
art(x)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue