Skip to content

ES6 module support for "type-only import" like goog.requireType or TS import type #3041

Open
@jplaisted

Description

@jplaisted

The type system currently has no way of referencing types in ES6 modules without importing them. We need some sort of weak reference / import type for ES6 modules.

Bike shedding ideas dump:

  1. Allow paths in type names. Use : as a delimiter for path:type.
/** @param {./foo.js:Type.Nested} n */
function foo(n) {}
  1. Some commented out import syntax that brings the names into the type scope.
// @import {Type} from './foo.js';

/** @param {Type.Nested} n */
function foo(n) {}
  1. Since the option above might be difficult with the current way we handle JsDoc (needs to be attached to something) and because Type doesn't really exist (it isn't a variable), we could modify the above option to act more like how we handle typedefs, i.e. annotate a variable declaration.
/** @import {Type} from './foo.js'; */
let Type;

/** @param {Type.Nested} n */
function foo(n) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ModulesfeatFeature Requestinternal-issue-createdAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions