Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add definition for define() #98

Closed
wants to merge 1 commit into from
Closed

Conversation

oktaal
Copy link

@oktaal oktaal commented Aug 25, 2017

I've added a TypeScript definition for the define() method in ace. I'm using this method to define a custom mode and include it.

Example custom mode declaration:

import 'brace/mode/abc'; // of course you can extend whatever mode you want
import * as ace from 'brace';
let AbcMode: { new(): any } = ace.acequire('ace/mode/abc').Mode;

export const modeName = 'my-custom-mode';
export default class MyCustomMode extends AbcMode {
    constructor() {
        super();
    }
}
ace.define(modeName, [], { Mode: MyCustomMode });

The mode can then simply be imported as follows:

import * as ace from 'brace';
import { modeName } from './my-custom-mode';

let editor = ace.edit(element);
let session = editor.getSession();
session.setMode(modeName);

@tbekolay
Copy link
Collaborator

Hi @oktaal, the TypeScript definitions here are generated by a script that makes slight modifications to the DefinitelyTyped typings. It would be best if you made your PR on the DefinitelyTyped definitions instead, so that we can pull those in here.

@thlorenz thlorenz closed this Nov 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants