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

Various TSX parsing errors #118

Closed
mjambon opened this issue Oct 3, 2020 · 1 comment
Closed

Various TSX parsing errors #118

mjambon opened this issue Oct 3, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@mjambon
Copy link
Member

mjambon commented Oct 3, 2020

TSX errors 2020-10-02

These are errors obtained on .tsx files from public repositories and
one of our private repositories. These are obtained by running
make stat from lang/tsx, which uses the tsx dialect of
tree-sitter-typescript.

The number indicates the number of errors encountered.

Some of these errors are not specific to the TSX grammar. See #115 for other typescript errors.

TSX elements with type parameters

5

<Element<Type> />;
        ^^^^^^

The official typescript implementation supports it.

The error node reported by the tree-sitter parser starts from the beginning of the
file, typically covering a large region, making it hard to figure out
what's wrong.

PR: tree-sitter/tree-sitter-typescript#92

Type of the form A extends B ? C : D - conditional types

4

type a = b extends c ? d : e

Also a problem with pure typescript. See issue semgrep/semgrep#1969

Nested empty/anonymous tag/element

3

<Elt>
            <>
             ^

This is an element with no name. It's a shorthand for <React.Fragment>.
Same problem exists in tree-sitter-javascript.

PR (merged): tree-sitter/tree-sitter-javascript#139

Type arguments on function call

const PolicyTree: React.FC<Props> = ({ policy }) => {
  const [nodes, setNodes] = useState<ITreeNode[]>();
                                                 ^^^

node type: ERROR
children: [
  formal_parameters
  ";"
]

Tracked at semgrep/semgrep#1992

New lines in string literals representing attributes

2

<path
  d='a
     ^
     b'
 />;

PR: tree-sitter/tree-sitter-typescript#91

Optional keys (?)

2

export type ChampsPokemonProps = { [P in keyof Pokemon]?: any } & {
                                                       ^
    showNickname?: boolean;
    showGender?: boolean;
node type: ERROR
children: [
  "?"
]

Also a problem observed for pure typescript.

Tracked at tree-sitter/tree-sitter-typescript#98

keyof typeof

2

    return `${baseURL}${isShiny}/${isFemaleSpecific}${formatSpeciesName(
        species,
    )}${getIconFormeSuffix(forme as keyof typeof Forme)}.png`;
                                                 ^^^^^
};

Also a problem observed for pure typescript. Tracked at tree-sitter/tree-sitter-typescript#99

Abstract class (?)

import AppConfig from './AppConfig';

export default abstract class AppBootstrapper {
               ^^^^^^^^
    constructor() {
        RX.App.initialize(__DEV__, __DEV__);

See semgrep/semgrep#1995.

@mjambon mjambon added the bug Something isn't working label Oct 3, 2020
@mjambon
Copy link
Member Author

mjambon commented Nov 10, 2020

Closing this because all the issues were simplified and either fixed or reported individually.

@mjambon mjambon closed this as completed Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant