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

TS 2.9.2 incorrectly imports symbol from file rather than from library #25026

Closed
gsbelarus opened this issue Jun 17, 2018 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@gsbelarus
Copy link

2.9.2 have broken my build process. After an investigation I found strange thing. There is a code which worked in previous version:

import { createToken, Lexer, IToken } from 'chevrotain';

export const WhiteSpace = createToken({
  name: 'WhiteSpace',
  pattern: /[ \t]+/,
  line_breaks: false
});
...

Now it produces incorrect type definition:

import { Lexer, IToken } from 'chevrotain';
export declare const WhiteSpace: import("../../../../../../Golden/NS/lib/gdmn-nlp/node_modules/chevrotain").TokenType;

When I specify type of constant directly all works well:

import { createToken, Lexer, IToken, TokenType } from 'chevrotain';

export const WhiteSpace: TokenType = createToken({
  name: 'WhiteSpace',
  pattern: /[ \t]+/,
  line_breaks: false
});

results into correct type definition:

import { Lexer, IToken, TokenType } from 'chevrotain';
export declare const WhiteSpace: TokenType;

The function CreateToken declared as:

export declare function createToken(config: ITokenConfig): TokenType

So, in the example above TS must know about type of constant and use type TokenType from library chevrotain instead of disk file.

@j-oliveras
Copy link
Contributor

Duplicate of #24980 and #24599.

Should be fixed into version 3. You can try it with a Nightly Build.

@DanielRosenwasser
Copy link
Member

Thanks @j-oliveras!

@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants