Skip to content

Allow compile-time computable expressions to initialize ambient consts #6804

Closed as not planned
@RyanCavanaugh

Description

@RyanCavanaugh

To support #6678, allow const declarations in ambient contexts to have compile-time computable initializers:

// foo.d.ts
const x = 'hello'; // OK
const y = 'hello ' + 'world' // OK
const z = 'hello'.substr(3); // Error

const a = 10; // OK
const b = 10 + 10; // OK
// Rest of rules follow from 'const enum' rules

const m = true; // OK
const n = false; // OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions