1
export declare class Config {
    readonly ROUTE_TYPE_CREATE: string;
}

import { Config } from "./Config";

export default class NewComponent {
    constructor() {
        this.routeType = Config.ROUTE_TYPE_CREATE;
    }
}

When I compile code, it returns:

ERROR in [at-loader] ./new.cpn.ts:12:33 
    TS2339: Property 'ROUTE_TYPE_CREATE' does not exist on type 'typeof Config'.

What is the problem? Why is it unaccessible?

1 Answer 1

3

You declared an instance property on Config, but not a static property named Config.ROUTE_TYPE_CREATE. Add static and it should work:

declare class Config {
    static readonly ROUTE_TYPE_CREATE: string; 
}

The error message hints at this, if you read it very carefully:

Property 'ROUTE_TYPE_CREATE' does not exist on type 'typeof Config'.

If you had an instance, that would read on type 'Config', but you're working with the class directly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.