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

Is there any intelligent code hint plugins for webstorm or vscode? #390

Closed
lowesyang opened this issue Dec 26, 2018 · 20 comments
Closed

Is there any intelligent code hint plugins for webstorm or vscode? #390

lowesyang opened this issue Dec 26, 2018 · 20 comments

Comments

@lowesyang
Copy link

A better code hint maybe improve the experience for developing assemblyscript~

@willemneal
Copy link
Contributor

vscode has good typescript support and assembly script is still valid typescript. For what it's worth, I use atom and it has type docs and explores type declarations.

@lowesyang
Copy link
Author

Yeah. But the new types provided by assemblyscript like u32, u64 will get error hints in vscode and webstorm. And built-in functions have no code hints.

@MaxGraey
Copy link
Member

try use this:

/// <reference path="../node_modules/assemblyscript/index.d.ts" />

@jtenner
Copy link
Contributor

jtenner commented Dec 27, 2018

FWIW I have a few comments here.

vscode has good typescript support and assembly script is still valid typescript.

There are plenty of differences between TypeScript and AssemblyScript. It's technically not a perfect subset of TypeScript. The following examples make things a bit clearer.

Example 1: Type Casting

function cast<T>(value: i32): T {
  return <T>value;
}

In this example we get the following error from the typescript even though this is 100% valid AssemblyScript, as long as the value can technically be cast at compile time.

Conversion of type 'number' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ts(2352)

I have suggested to @dcodeIO and @MaxGraey that we could use a number type, and they suggested that it might default to f64 so that we can do type extension like this, and quelch the generator error in TypeScript world:

function cast<T extends number>(value: i32): T {
  return <T>value;
}

Yeah. But the new types provided by assemblyscript like u32, u64 will get error hints in vscode and webstorm. And built-in functions have no code hints.

Yep. When using vscode, for instance, whenever I use a type backed by number, there are no code hints for converting between the number types. All numbers are treated like f64 in the ide regardless of strict typing in AssemblyScript. In order to fix a problem like this, we would need to adopt a new file extension and create language a support extension just for AssemblyScript in vscode. Syntax highlighting can be offset onto the TypeScript syntax highlighting, obviously.

Example 2: Type Annotations

@external("my", "imported", "function")
declare function imported_function(): void;

This results in...

Decorators are not valid here.ts(1206)

Of course, annotations don't belong on function declarations, or on inline functions. They usually only appear on class members to modify the class prototype. This is because TypeScript is guided by the ecmascript specification, wheras AssemblyScript has it's own parser/compiler combo and has a great use-case for annotations like @inline and @operator that might not appear on class members.

I think there is a great use case for creating an AssemblyScript plugin for ides, but that should definitely be discussed in a RFC thread.

@vgrichina
Copy link

@jtenner I think making some patches to https://github.com/Microsoft/monaco-typescript is going to give biggest bang for buck.
There are likely only small changes needed (to ignore some warnings) and it's going to cover VSCode + variety of web IDEs using Monaco.

@jtenner
Copy link
Contributor

jtenner commented Feb 2, 2019

The question is how do you differentiate between code written for assemblyscript and code written in typescript?

@vgrichina
Copy link

The question is how do you differentiate between code written for assemblyscript and code written in typescript?

There is tsconfig.json for that.

@stale
Copy link

stale bot commented Mar 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Mar 9, 2019
@stale
Copy link

stale bot commented Apr 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 9, 2019
@ExE-Boss
Copy link

ExE-Boss commented Apr 9, 2019

Well, differentiating between the different int types depends on microsoft/TypeScript#202.

@stale stale bot removed the stale label Apr 9, 2019
@dcodeIO
Copy link
Member

dcodeIO commented Apr 9, 2019

Interesting that this has actually be discussed at TypeScript. Not too optimistic that this'll ever happen, though. My expectation at this point is that we'll have to create our own language service eventually, possibly switching to an .as extension.

@stale
Copy link

stale bot commented May 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 9, 2019
@stale stale bot closed this as completed May 16, 2019
@ExE-Boss
Copy link

Is there a way to tell @stale[bot] not to close an issue?

@MaxGraey MaxGraey reopened this May 16, 2019
@stale stale bot removed the stale label May 16, 2019
@dcodeIO
Copy link
Member

dcodeIO commented May 16, 2019

It's currently configured to automatically mark issues without further activity as stale and close them after a while if no new activity happens, unless tagged as enhancement, bug or likewise. So far I considered this issue a question, but looks its more of an enhancement request now?

@trusktr
Copy link
Member

trusktr commented May 27, 2019

Is there currently a way to to tell TypeScript (not AssemblyScript) not to complain about decorators are not valid here?

I'm using Atom with the atom-typescript plugin, so that I can get all the IDE features.

@dcodeIO
Copy link
Member

dcodeIO commented May 27, 2019

We use // @ts-ignore, which will ignore the next line in AS, but not sure if a missing decorator like that will compile with tsc.

@trusktr
Copy link
Member

trusktr commented May 27, 2019

Ah, true, it won't compile anyways. So looks like the trick of putting those imports in a separate file (like in #384 (comment)) may be the way to do it.

I will also look at exporting getFour from a module. Then maybe a Babel or Gulp step before asc can supply the @external code.

@onionhammer
Copy link

onionhammer commented Feb 16, 2020

Regarding the @external decorator on declarations; If it's not valid TypeScript, should it be valid AssemblyScript? I thought AS was a subset of TS?

@MaxGraey
Copy link
Member

MaxGraey commented Feb 16, 2020

in some parts it's stricter subset (no any and undefined, no dynamic properties, nominal type system) in some part it's superset (more integer and float types, operator overloading, builtin decorators over functions and declarations and etc)

@dcodeIO
Copy link
Member

dcodeIO commented May 27, 2020

Closing this issue as part of 2020 vacuum because it is more a question, with a solution being discussed elsewhere as part of creating a custom language server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants