Skip to content

Allow pure ECMAScript block #1644

Closed
Closed
@NN---

Description

@NN---

Motivation:
TypeScript currently doesn't support all ES6 features and it takes time for supporting them.
Moreover each vendor plays with new ES extensions like ES7 draft and so on.

Proposal:
Allow pure ECMAScript block which is not treated as TypeScript.
It is pretty similar to '_asm' directive in C language.

This allows to use generators of ES6 while TS doesn't support them:

__ecmascript {
  function *foo() {
    yield 1;
  }
}

// Since the block is not parsed by the TS compiler we must declare the function.
declare extern foo() : any;
var it = foo();
var value = it.next();

Or 'const' which is not supported in TS 1.3:

__ecmascript {
  const A = 1;
}

// Declaring 'A' to be used in the code.
// TS compiler doesn't protect us from assigning to 'A' but ES engine does.
declare var A : number;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Out of ScopeThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions