Reputation: 13529
I have a namespace in typescript that looks like this :
export declare namespace MyNamespace {
const myFunc = (a:number) => 3;
}
My compiler complains about the function that :
TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference
What is this error trying to tell me? I cannot have a function as a const within a namespace?
Upvotes: 13
Views: 12948
Reputation: 111
This error may happen if you are inside a d.ts
file, which only allows type declarations. Try a .ts
file instead!
Here is a related question: Initializers are not allowed in ambient contexts error when installing Blueprint
Upvotes: 11