Skip to content

Causes breaking code changes at worst, ugly code at best for TypeScript without semicolons #15

@iferc

Description

@iferc

The following input is automatically generated by the Vue3 CLI in a shim file named shims-vue.d.ts when making a new TypeScript Vue3 project. The auto-generated code lacks semicolons by default. This default generated code completely breaks once formatted.

Input 1:

declare module '*.vue' {
  import type {DefineComponent} from 'vue'
  const component: DefineComponent <{}, {}, any>
  export default component
}

Output 1:

declare module '*.vue' {
  import type {DefineComponent}
  from 'vue'
  const component: DefineComponent < {}, {},
    any > export default component
}

Expected behavior 1:

declare module '*.vue' {
  import type {DefineComponent} from 'vue'
  const component: DefineComponent < {}, {}, any >
  export default component
}

So it might seem that the issue is the lack of semicolons. With them added, the code no longer breaks, but is very oddly formatted that produces less legible code.

Input 2:

declare module '*.vue' {
  import type {DefineComponent} from 'vue';
  const component: DefineComponent <{}, {}, any>;
  export default component;
}

Output 2:

declare module '*.vue' {
  import type {DefineComponent}
  from 'vue';
  const component: DefineComponent < {}, {},
    any >;
  export default component;
}

Expected behavior 2:

declare module '*.vue' {
  import type {DefineComponent} from 'vue';
  const component: DefineComponent < {}, {}, any >;
  export default component;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions