microsoft / TypeScript-Website

The Website and web infrastructure for learning TypeScript
https://www.typescriptlang.org
Creative Commons Attribution 4.0 International
2.23k stars 1.37k forks source link

Module: Twoslash multi-file support weird when there's no index.ts #728

Closed orta closed 4 years ago

orta commented 4 years ago

Improvement Idea:

// @emitDecoratorMetadata
// @experimentalDecorators
// @showEmit
// @filename: service.ts
export class Service {}

// @filename: component.ts
import type { Service } from "./service"

Creates these virtual files:

     [
        [ '', [ '// @filename: ' ] ],
        [
          'service.ts',
          [ '// @filename: service.ts', 'export class Service {}', '', '' ]
        ],
        [
          'component.ts',
          [
            '// @filename: component.ts',
            'import type { Service } from "./service"',
            '',
            'declare var decorator: any',
            '',
            '@decorator',
            'class MyComponent {',
            '  constructor(public Service: Service) {}',
            '',
            '  @decorator',
            '  method(x: this) {}',
            '}',
            ''
          ]
        ]
      ]

Why:

The file generation from a single file is too simple

orta commented 4 years ago

This should be fixed by #729

orta commented 4 years ago

It is