Skip to content

A ES6 module with with multiple exports including a default export #2440

@tinganho

Description

@tinganho

I'm not sure if this is valid ES6 code but I'm trying to get this work:
app.ts

import function1, { function2 } from './module1'

function1()
function2()

module1.ts

export default function function1() {
  console.log('hej')
}

export function function2() {
  console.log('hej')
}

I'm using today's master branch and I get the following error when I compile app.ts:

error TS2309: An export assignment cannot be used in a module with other exported elements.

An another question, if app.ts do a namespaced import will I have access to the default function too?

app.ts

import * as module1 from './module1'

module1.function1()
module2.function2()

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions