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

Class constructors undefined #6

Closed
banacorn opened this issue May 25, 2016 · 17 comments
Closed

Class constructors undefined #6

banacorn opened this issue May 25, 2016 · 17 comments
Labels

Comments

@banacorn
Copy link
Collaborator

banacorn commented May 25, 2016

I can reference some types such as Point like this:

let p: atom.Typings.Point;

But not it's constructor:

let p = new atom.Typings.Point(1, 2);

The line above can be type checked, but will crash on runtime, because atom.Typings is undefined, am I using it the wrong way?

@unional
Copy link
Collaborator

unional commented May 25, 2016

Very valid point. When I created the typings I was expecting everything under atom.Typings to contain interface only, not class. It does not work with class.

I painstakingly went through the whole document to add all typings in. But for those classes I didn't know how to access them (it was not described in the doc).

As now I look into it, it is from here: https://github.com/atom/text-buffer/blob/master/src/point.coffee

Do you know how to access it in js? We can then refactor it to put it in the right place.

@unional
Copy link
Collaborator

unional commented May 25, 2016

Ok. I found it. It can be accessed under:

import a = require('atom');
a.Point;
a.TextBuffer.Point;

Will see if I can pull the relevant types into the module (instead of the global atom)

@unional unional added the bug label May 25, 2016
@banacorn
Copy link
Collaborator Author

banacorn commented May 25, 2016

Yes, it can be accessed like that, but the typechecker would complain.

While these classes seem perfectly fine to be accessed.

/// <reference path="./atom-namespace.d.ts" />

declare module 'atom' {
  export var BufferedNodeProcess: atom.Typings.BufferedNodeProcess;
  export var BufferedProcess: atom.Typings.BufferedProcess;
  export var CompositeDisposable: atom.Typings.CompositeDisposable;
  export var Task: atom.Typings.Task;
}

@banacorn
Copy link
Collaborator Author

I think we should move everything to the module while leaving only the properties of AtomEnvironment in the global atom.

@unional
Copy link
Collaborator

unional commented May 25, 2016

Yes. That what I mean by "pull the relevant types into the module"

@unional
Copy link
Collaborator

unional commented May 25, 2016

Actually there are many things on the AtomEnvironment:

      "blobStore",
      "applicationDelegate",
      "window",
      "document",
      "configDirPath",
      "enablePersistence",
      "unloaded",
      "loadTime",
      "emitter",
      "disposables",
      "stateStore",
      "deserializers",
      "deserializeTimings",
      "views",
      "notifications",
      "config",
      "keymaps",
      "tooltips",
      "commands",
      "grammars",
      "styles",
      "packages",
      "themes",
      "menu",
      "contextMenu",
      "clipboard",
      "project",
      "appVersion",
      "commandInstaller",
      "workspace",
      "textEditors",
      "autoUpdater",
      "initialStyleElements",
      "stylesElement",
      "previousWindowErrorHandler",
      "windowEventHandler",
      "constructor",
      "lastUncaughtError",
      "saveStateDebounceInterval",
      "attachSaveStateListeners",
      "setConfigSchema",
      "registerDefaultDeserializers",
      "registerDefaultCommands",
      "registerDefaultViewProviders",
      "registerDefaultOpeners",
      "registerDefaultTargetForKeymaps",
      "observeAutoHideMenuBar",
      "reset",
      "destroy",
      "onDidBeep",
      "onWillThrowError",
      "onDidThrowError",
      "onDidFailAssertion",
      "inDevMode",
      "inSafeMode",
      "inSpecMode",
      "isFirstLoad",
      "getVersion",
      "getReleaseChannel",
      "isReleasedVersion",
      "getWindowLoadTime",
      "getLoadSettings",
      "open",
      "pickFolder",
      "close",
      "getSize",
      "setSize",
      "getPosition",
      "setPosition",
      "getCurrentWindow",
      "center",
      "focus",
      "show",
      "hide",
      "reload",
      "isMaximized",
      "maximize",
      "isFullScreen",
      "setFullScreen",
      "toggleFullScreen",
      "displayWindow",
      "getWindowDimensions",
      "setWindowDimensions",
      "isValidDimensions",
      "storeWindowDimensions",
      "getDefaultWindowDimensions",
      "restoreWindowDimensions",
      "restoreWindowBackground",
      "storeWindowBackground",
      "startEditorWindow",
      "serialize",
      "unloadEditorWindow",
      "openInitialEmptyEditorIfNecessary",
      "installUncaughtErrorHandler",
      "uninstallUncaughtErrorHandler",
      "installWindowEventHandler",
      "uninstallWindowEventHandler",
      "beep",
      "confirm",
      "openDevTools",
      "toggleDevTools",
      "executeJavaScriptInDevTools",
      "assert",
      "loadThemes",
      "watchProjectPaths",
      "setDocumentEdited",
      "setRepresentedFilename",
      "addProjectFolder",
      "showSaveDialog",
      "showSaveDialogSync",
      "saveBlobStoreSync",
      "saveState",
      "loadState",
      "deserialize",
      "getStateKey",
      "getStorageFolder",
      "getConfigDirPath",
      "getUserInitScriptPath",
      "requireUserInitScript",
      "onUpdateAvailable",
      "updateAvailable",
      "listenForUpdates",
      "setBodyPlatformClass",
      "setAutoHideMenuBar",
      "dispatchApplicationMenuCommand",
      "dispatchContextMenuCommand",
      "openLocations",
      "alive",
      "assignId",
      "isAlive",
      "isDestroyed"

Some of them are either private or not documented.

@banacorn
Copy link
Collaborator Author

banacorn commented Jun 1, 2016

Hi, how can I contribute to this repo?
I want the typings so badly :D

@unional
Copy link
Collaborator

unional commented Jun 1, 2016

Sorry, didn't have time to work on it since last week.

I have added you to this and other related projects. Feed free to give them some love.

Remaining work:

  • Fix npm-text-buffer repo
  • Use event-kit atom-keymap path-watcher text-buffer and first-mate repo in this repo
  • Fix up any remaining issues.

@unional
Copy link
Collaborator

unional commented Jun 1, 2016

Ah, I was having some difficulty on this: typings/discussions#15 (comment)

@unional
Copy link
Collaborator

unional commented Jun 2, 2016

Still have a few files left.

@unional
Copy link
Collaborator

unional commented Jun 2, 2016

@banacorn , I don't have time to work on it for the next few days, can you fix the files starting from text-editor.d.ts? There are only a few files left. Take a look at other files to see how to fix them.

Then we can test. Thanks.

@banacorn
Copy link
Collaborator Author

banacorn commented Jun 2, 2016

This is the best typings for Atom I can find on the planet, thanks for inviting me to this repo. I'll be happy to fix them.

@banacorn
Copy link
Collaborator Author

I've managed to clear all of the type errors, but I have no idea what should I do next (or what I've been doing).

Is there a brain dead simple typings publish tutorial? Or something like typings publish, this is all just too frustrating for me :(

@unional
Copy link
Collaborator

unional commented Jun 11, 2016

Huge thanks! I'll check it out. If it works, then the next and last step is updating https://github.com/typings/registry/blob/master/env/atom.json

@unional
Copy link
Collaborator

unional commented Jun 12, 2016

Good news. I got it working.

Checking in to registry now:
typings/registry#544

@unional
Copy link
Collaborator

unional commented Jun 12, 2016

Is there a brain dead simple typings publish tutorial? Or something like typings publish, this is all just too frustrating for me :(

I'm working on generator-typings and when I get the github part working, I'll be adding the publish function there. When it is ready, I believe the cmd would be:

yo typings:publish or something similar

@unional
Copy link
Collaborator

unional commented Jun 12, 2016

The test https://github.com/typed-typings/env-atom/blob/master/spec/atom-spec.ts#L21
covered this case. Closing this issue.

If you found other issue, feel free to open new ones. 🌷

@unional unional closed this as completed Jun 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants