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

Suppressing specific error and warnings #451

Open
pdesaulniers opened this issue May 27, 2021 · 2 comments
Open

Suppressing specific error and warnings #451

pdesaulniers opened this issue May 27, 2021 · 2 comments
Labels
feature request New feature or request

Comments

@pdesaulniers
Copy link
Member

pdesaulniers commented May 27, 2021

Related issue: teal-language/vscode-teal#41

The TypeScript compiler allows suppressing errors and warnings using a // @ts-ignore comment above the offending line:

var x: number = 123;

// @ts-ignore: The compiler will suppress the error below
x = "hello";

It also supports // @ts-nocheck at the top of files for suppressing errors in a whole file.

Would it make sense to add a similar feature in tl? I suppose it could be useful when migrating Lua codebases to Teal, to make the porting task more manageable.

Some potential concerns:

  • Not sure if processing comments in the compiler is a good idea...
  • These annotations could be handled by a separate tool, outside of the compiler.
@pdesaulniers pdesaulniers changed the title Suppressing error and warnings using comments Suppressing specific error and warnings Jun 6, 2021
@hishamhm
Copy link
Member

hishamhm commented Jun 7, 2021

I don't think the core compiler should process those comments, but perhaps the parser could preserve them for use by other tools as in the experimental preserve-comments branch. Still, that branch only stores the comments in the AST, it does not expose them via tl types. But I think Cyan for example is using the API, so it would be a matter of adding API functionality in that branch to obtain comments [*], if that's a feature that's wanted in the build tool.

[*] if we add a public API to read comments from the source, it would be good to consider also other use-cases such as documentation generation. (Is tealdoc using its own parser? @SovietKitsune ?)

@Sylviettee
Copy link
Contributor

Tealdoc uses its own parser for comments by using the y position on each of the types.
Shiroko (a Teal linter) currently only looks at the end of a line for an ignore comment.

local x: someInvalidType -- shiroko: allow(tlCheck)

@hishamhm hishamhm added the feature request New feature or request label Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants