Skip to content

Code Quill.import('mod'); makes TS think it needs to import('mod') #23359

Closed
@joscha

Description

@joscha

The quill library has a static method called import on it's exported symbol, which is used like this:

Quill.import('dependency');

These dependencies are not actually imports, they are strings in a map. Unfortunately ts.preProcessFile thinks they are valid imports.
I tried fixing the issue, but there is some logic missing and I am unsure how to debug the test I added properly with me being able to look at the scanner state. Maybe someone can give me a hint on how to complete my fix in #23358, please?

TypeScript Version: master (edcf087)

Search Terms: Quill, .import, static import, preprocessFiles

Code

Quill.import('delta');

see https://github.com/Microsoft/TypeScript/pull/23358/files#diff-fa5d406e8b31aa069cd80d9698ca0590R63

Expected behavior:
Quill.import('delta'); is treated like any other code (a function call of the function import on a symbol Quill)

Actual behavior:
TS thinks this is a proper import a la import('delta'), ignoring the fact that there is a preceding Quill..

Playground Link: See #23358

Related Issues:
#23358

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptBugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions