neutralinojs / neutralinojs-cli

neu cli for Neutralinojs
https://neutralino.js.org/docs/cli/neu-cli
MIT License
91 stars 56 forks source link

also download types during `neu create` #219

Closed alsuren closed 11 months ago

alsuren commented 11 months ago

Fixes #79

After this patch is applied, it will create neutralino.d.ts next to neutralino.ts in resources/js.

In order to make this work with the default template, you make the following changes to resources/js/main.js

1) add

// @ts-check

2) add

import './neutralino.js'

3) add a // @ts-ignore to ignore the Object is possibly 'null'. error from document.getElementById('info').innerHTML = ... (or add a runtime check that the element is not null).

You also need to add neutralino.d.ts to .gitignore, like how neutralino.js is already ignored in the template.

Once this is done, you get IDE tab completion and hints for Neutralino.filesystem.readDirectory and NL_CWD etc. (in vscode) without needing to add any bulid steps.

shalithasuranga commented 11 months ago

The types file won't be copied to the app bundle (https://github.com/neutralinojs/neutralinojs-cli/commit/d05d5cbf12cc534f68faa85c77dede131f60b179)