-
Notifications
You must be signed in to change notification settings - Fork 60
Feat: add completion toplevel decorators #799
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
type kind = TopLevel of string | Local of string | TopLevelOrLocal of string | ||
|
||
let decorators = | ||
[ | ||
( "as", | ||
( Local "as", | ||
[ | ||
{|The `@as` decorator is commonly used on record types to alias record field names to a different JavaScript attribute name. | ||
|
||
|
@@ -10,7 +12,7 @@ It is also possible to map a ReScript record to a JavaScript array by passing in | |
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#as-decorator).|}; | ||
] ); | ||
( "dead", | ||
( Local "dead", | ||
[ | ||
{|The `@dead` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis. | ||
|
||
|
@@ -20,21 +22,21 @@ It is also possible to map a ReScript record to a JavaScript array by passing in | |
|
||
> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; | ||
] ); | ||
( "deriving", | ||
( Local "deriving", | ||
[ | ||
{|When the `@deriving` decorator is applied to a record type, it expands the type into a factory function plus a set of getter/setter functions for its fields. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#deriving-decorator).|}; | ||
] ); | ||
( "deprecated", | ||
( TopLevelOrLocal "deprecated", | ||
[ | ||
{|The `@deprecated` decorator is used to add deprecation notes to types, values and submodules. The compiler and editor tooling will yield a warning whenever a deprecated entity is being used. | ||
|
||
Alternatively, use the `@@deprecated` decorator to add a deprecation warning to the file level. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this really be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add here e3e0463 |
||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#expression-deprecated-decorator).|}; | ||
] ); | ||
( "doesNotRaise", | ||
( Local "doesNotRaise", | ||
[ | ||
{|The `@doesNotRaise` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. | ||
|
||
|
@@ -45,55 +47,55 @@ could potentially raise. | |
[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). | ||
> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; | ||
] ); | ||
( "genType", | ||
( Local "genType", | ||
[ | ||
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#gentype-decorator).|}; | ||
] ); | ||
( "genType.as", | ||
( Local "genType.as", | ||
[ | ||
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; | ||
] ); | ||
( "genType.import", | ||
( Local "genType.import", | ||
[ | ||
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; | ||
] ); | ||
( "genType.opaque", | ||
( Local "genType.opaque", | ||
[ | ||
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; | ||
] ); | ||
( "get", | ||
( Local "get", | ||
[ | ||
{|The `@get` decorator is used to bind to a property of an object. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-decorator).|}; | ||
] ); | ||
( "get_index", | ||
( Local "get_index", | ||
[ | ||
{|The `@get_index` decorator is used to access a dynamic property on an object, or an index of an array. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-index-decorator).|}; | ||
] ); | ||
( "inline", | ||
( Local "inline", | ||
[ | ||
{|The `@inline` decorator tells the compiler to inline its value in every place the binding is being used, rather than use a variable. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#inline-decorator).|}; | ||
] ); | ||
( "int", | ||
( Local "int", | ||
[ | ||
{|The `@int` decorator can be used with polymorphic variants and the @as decorator on externals to modify the compiled JavaScript to use integers for the values instead of strings. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#int-decorator).|}; | ||
] ); | ||
( "live", | ||
( Local "live", | ||
[ | ||
{|The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis. | ||
|
||
|
@@ -103,32 +105,32 @@ could potentially raise. | |
|
||
Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; | ||
] ); | ||
( "meth", | ||
( Local "meth", | ||
[ | ||
{|The `@meth` decorator is used to call a function on a JavaScript object, and avoid issues with currying. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#meth-decorator).|}; | ||
] ); | ||
( "module", | ||
( Local "module", | ||
[ | ||
{|The `@module` decorator is used to bind to a JavaScript module. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-decorator).|}; | ||
] ); | ||
( "new", | ||
( Local "new", | ||
[ | ||
{| | ||
The `@new` decorator is used whenever you need to bind to a JavaScript class constructor that requires the new keword for instantiation.| | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#new-decorator).|}; | ||
] ); | ||
( "obj", | ||
( Local "obj", | ||
[ | ||
{|The `@obj` decorator is used to create functions that return JavaScript objects with properties that match the function's parameter labels. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#obj-decorator).|}; | ||
] ); | ||
( "raises", | ||
( Local "raises", | ||
[ | ||
{|The `@raises` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. | ||
|
||
|
@@ -138,7 +140,7 @@ Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions. | |
[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). | ||
> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; | ||
] ); | ||
( "react.component", | ||
( Local "react.component", | ||
[ | ||
{|The `@react.component` decorator is used to annotate functions that are RescriptReact components. | ||
|
||
|
@@ -148,76 +150,89 @@ Note: The `@react.component` decorator requires the react-jsx config to be set i | |
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator).|}; | ||
] ); | ||
( "return", | ||
( Local "return", | ||
[ | ||
{|The `@return` decorator is used to control how `null` and `undefined` values are converted to option types in ReScript. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#return-decorator).|}; | ||
] ); | ||
( "scope", | ||
( Local "scope", | ||
[ | ||
{|The `@scope` decorator is used with other decorators such as `@val` and `@module` to declare a parent scope for the binding. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#scope-decorator).|}; | ||
] ); | ||
( "send", | ||
( Local "send", | ||
[ | ||
{|The `@send` decorator is used to bind to a method on an object or array. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#send-decorator).|}; | ||
] ); | ||
( "set", | ||
( Local "set", | ||
[ | ||
{|The `@set` decorator is used to set a property of an object. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-decorator).|}; | ||
] ); | ||
( "set_index", | ||
( Local "set_index", | ||
[ | ||
{|The `@set_index` decorator is used to set a dynamic property on an object, or an index of an array. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-index-decorator).|}; | ||
] ); | ||
( "string", | ||
( Local "string", | ||
[ | ||
{|The `@string` decorator can be used with polymorphic variants and the `@as` decorator on externals to modify the string values used for the variants in the compiled JavaScript. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#string-decorator).|}; | ||
] ); | ||
( "this", | ||
( Local "this", | ||
[ | ||
{|The `@this` decorator may be used to bind to an external callback function that require access to a this context. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#this-decorator).|}; | ||
] ); | ||
( "unboxed", | ||
( Local "unboxed", | ||
[ | ||
{|The `@unboxed` decorator provides a way to unwrap variant constructors that have a single argument, or record objects that have a single field. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unboxed-decorator).|}; | ||
] ); | ||
( "uncurry", | ||
( Local "uncurry", | ||
[ | ||
{|The `@uncurry` decorator can be used to mark any callback argument within an external function as an uncurried function without the need for any explicit uncurried function syntax (`(.) => { ... }`). | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#uncurry-decorator).|}; | ||
] ); | ||
( "unwrap", | ||
( Local "unwrap", | ||
[ | ||
{|The `@unwrap` decorator may be used when binding to external functions that accept multiple types for an argument. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unwrap-decorator).|}; | ||
] ); | ||
( "val", | ||
( Local "val", | ||
[ | ||
{|The `@val` decorator allows you to bind to JavaScript values that are on the global scope. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#val-decorator).|}; | ||
] ); | ||
( "variadic", | ||
( Local "variadic", | ||
[ | ||
{|The `@variadic` decorator is used to model JavaScript functions that take a variable number of arguments, where all arguments are of the same type. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#variadic-decorator).|}; | ||
] ); | ||
( TopLevel "directive", | ||
[ | ||
{|The `@@directive` decorator will output that string verbatim at the very top of the generated JavaScript file, before any imports. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#directive-decorator).|}; | ||
] ); | ||
( TopLevel "warning", | ||
[ | ||
{|The `@@warning` decorator is used to modify the enabled compiler warnings for the current module. See here for all available warning numbers. | ||
|
||
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-warning-decorator). | ||
|}; | ||
] ); | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.