Skip to content

Cannot define a module for a specific file extension in 2.4.1 #16769

Closed

Description

TypeScript Version: 2.4.1
Code

// A *self-contained* demonstration of the problem follows...
declare module "*.vue" {
  import Vue from 'vue'
  export default typeof Vue
}

Expected behavior:
A file with the above content used to work when importing .vue files.
In 2.4.1 It looks like the file is not taken into account as every .vue file gets imported as "string"?
Actual behavior:
Everything seems to be imported as string?

Activity

  1. vekexasia commented on Jun 27, 2017

    @vekexasia
    Author

    That file is perfectly working in 2.3.4

  2. mhegazy commented on Aug 23, 2017

    @mhegazy
    Contributor

    The right hand side of an export default is an expression not a type. typeof Vue is just calling the regular JS typeof operator on the reference Vue; and that happens to be a string all the time..

    This should have been an error to have an expression in an ambient context. the only possible value should be an identifier name. files #17991 to track it.

    so for this definition, you need to change your declaration to be:

    declare module "*.vue" {
        import Vue from 'vue'
        const _: typeof Vue;
        export default _;
    }
  3. mhegazy commented on Sep 7, 2017

    @mhegazy
    Contributor

    Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

  4. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions