Skip to content

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

Closed
@gsbelarus

Description

@gsbelarus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions