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

Not compatible with estree (Type 'BlockStatement' is not assignable to type 'Statement') #382

Closed
ndelangen opened this issue Mar 27, 2019 · 1 comment
Labels
bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@ndelangen
Copy link
Contributor

What code were you trying to parse?
The code parsed correctly

import path from 'path';
import { create } from '@storybook/theming';

export const entries = /\..*story\..*/;
export const preview = {};
export const manager = {};
export const theme = create({ brandTitle: 'test' });

export const presets = [];
export const addons = [''];

export const previewInit = '.storybook/config.js';
export const managerInit = '.storybook/addons.js';

export const unused = z => path.join('base', z);

I parse this using:

import { parse, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
import { generate } from 'astring';

const raw = 'code above';

const options = {
  range: false,
  loc: false,
  comment: false,
  jsx: true,
  useJSXTextNode: true,
};

const ast = parse(raw, options);

// I do some mutations to the ast

// I try to generate code
generate(ast); // <-- this causes type errors

What did you expect to happen?
No type errors

What actually happened?

src/preshake.ts(75,19): error TS2345: Argument of type 'Program' is not assignable to parameter of type 'Node'.
  Type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-estree").Program' is not assignable to type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@types/estree/index").Program'.
    Types of property 'body' are incompatible.
      Type 'Statement[]' is not assignable to type '(FunctionDeclaration | ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ... 15 more ... | ExportAllDeclaration)[]'.
        Type 'Statement' is not assignable to type 'FunctionDeclaration | ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ... 15 more ... | ExportAllDeclaration'.
          Type 'BlockStatement' is not assignable to type 'FunctionDeclaration | ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ... 15 more ... | ExportAllDeclaration'.
            Type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-estree").BlockStatement' is not assignable to type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@types/estree/index").BlockStatement'.
              Types of property 'body' are incompatible.
                Type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-estree").Statement[]' is not assignable to type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@types/estree/index").Statement[]'.
                  Type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-estree").Statement' is not assignable to type 'import("/Users/dev/Projects/GitHub/storybook/core/node_modules/@types/estree/index").Statement'.
                    Type 'BlockStatement' is not assignable to type 'Statement'.

Versions

package version
@typescript-eslint/typescript-estree 1.5.0
TypeScript 3.3.3333
node 8.11.3
npm 5.6.0
@ndelangen ndelangen added package: typescript-estree Issues related to @typescript-eslint/typescript-estree triage Waiting for maintainers to take a look labels Mar 27, 2019
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for maintainers to take a look labels Mar 27, 2019
@bradzacher
Copy link
Member

Fixed in #378

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

No branches or pull requests

2 participants