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

[FEATURE] Type Hints (Discussion) #670

Open
1 task done
Jason2605 opened this issue Sep 29, 2023 · 3 comments
Open
1 task done

[FEATURE] Type Hints (Discussion) #670

Jason2605 opened this issue Sep 29, 2023 · 3 comments
Labels
feature request Discussion about a new feature

Comments

@Jason2605
Copy link
Member

Jason2605 commented Sep 29, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

Building out a fully blown type system is probably a little above my pay grade, however, what we can potentially do is add type hints into dictu. These would function exactly the same as Python's type hints (which are essentially glorified comments) but will allow us to use external tools to check for things, or even just provide a little more clarity to the developer about a type even if there isn't actually any checking taking place

Describe the solution you'd like

Something along the lines of:

const myString: string = "hello!!";
const myString -> string = "hello!!";

def lengthGreatherThanFive(myString: string): boolean {
    return myString.len() > 5;
}

def lengthGreatherThanFive(myString -> string) -> boolean {
    return myString.len() > 5;
}

// Maybe a mix?
def lengthGreatherThanFive(myString: string) -> boolean {
    return myString.len() > 5;
}

Describe alternatives you've considered

No response

Additional context

No response

@Jason2605 Jason2605 added the feature request Discussion about a new feature label Sep 29, 2023
@briandowns
Copy link
Contributor

Definitely in favor of the : option.

@RevengerWizard
Copy link
Contributor

Python's way of handling type hints is especially tricky and weird, given that it treats everything after the : or -> as a normal language expression that doesn't produce any bytecode, essentially a comment.

It's also interesting how Typescript, but usually Javascript, handle type hints inside separate .d.ts files which basically only contain the relevant hints to functions, classes and attributes.

@Jason2605
Copy link
Member Author

Python's way of handling type hints is especially tricky and weird, given that it treats everything after the : or -> as a normal language expression that doesn't produce any bytecode, essentially a comment.

I was thinking something similar, except unlike python, it doesn't even need to be a valid identifier (will massively simplify things for us).

Yeah the d.ts files allow you to have type information about some public API written in JS, I think for us, we'd probably just have it mixed into the actual source file (rather than a separate dedicated file) - again will be simpler to implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Discussion about a new feature
Projects
None yet
Development

No branches or pull requests

3 participants