Skip to content

TS1450 (wrong number of import() arguments) is reported with category "message" instead of "error" #65309

Description

@trackoor

🔎 Search Terms

TS1450, Dynamic imports can only accept a module specifier and an optional set of attributes as arguments, import() no arguments, diagnostic category message

🕗 Version & Regression Information

This is the behavior in every version I tried: 5.9.3, 6.0.3, 7.0.2, 7.1.0-dev.20261103.1 (typescript@next) and main e2bc2bc. Not a regression.

⏯ Playground Link

No response

💻 Code

export {};
import();
import("./t.js", {}, "");
import(...["./t.js"]);

🙁 Actual behavior

tsc --noEmit --target esnext --module esnext --pretty false t.ts:

t.ts(2,1): message TS1450: Dynamic imports can only accept a module specifier and an optional set of attributes as arguments
t.ts(3,1): message TS1450: Dynamic imports can only accept a module specifier and an optional set of attributes as arguments
t.ts(4,8): error TS1325: Argument of dynamic import cannot be spread element.

TS1450 is printed as message, while the neighbouring grammar error for the same call (TS1325) is an error. The language server maps category Message to DiagnosticSeverity.Information (diagnosticSeverity in internal/ls/lsconv/converters.go), so in the editor import() gets an information marker instead of an error, and tools that filter diagnostics by category treat the file as error-free.

🙂 Expected behavior

error TS1450: …, like the other grammar errors on import calls. Both calls are syntax errors: ImportCall : import ( AssignmentExpression ,opt ) | import ( AssignmentExpression , AssignmentExpression ,opt ) (https://tc39.es/ecma262/#sec-import-calls). node rejects the file with SyntaxError: import() requires a specifier.

Additional information about the issue

In internal/diagnostics/diagnosticMessages.json the entry has "category": "Message", "code": 1450. Among codes below 3000 it is the only Message-category entry that reports a problem in the user's code; the other Message entries are "File is included via …" explanations, quick-fix titles and option descriptions (it sits right after 1449, an option description). Changing the category to "Error" and regenerating would turn message TS1450 into error TS1450 in the 8 reference baselines that contain it (importAssertion1, importAttributes1, importCallExpressionGrammarError, importSource5, importSource11, plainJSGrammarErrors).

Activity

  1. RyanCavanaugh commented on Nov 4, 2026

    @RyanCavanaugh
    Member

    Linked PR is good but we should have had an assert that catches this earlier too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions