Skip to content

respect settings in tsconfig when creating TypeScript-AST in parseComponents #2

Open
@michaelbe812

Description

@michaelbe812

Issue origins out of discussion on this PR

Background info

In this PR a parseComponents function was introduced which reads Ts-files and transforms it to a TS-AST.

In this method we find this piece of code

  const program = ts.createProgram([...filePaths], {
    target: ts.ScriptTarget.Latest,
    module: ts.ModuleKind.ESNext,
    experimentalDecorators: true,
  });

As we can see the values for target, module and experimentalDecorators are hard-coded.

Potential issues with this approach

Mainly we risk inconsistencies or even creating a wrong AST which can lead to wrong results and/or unexpected runtime errors.

Even worse: it will be extremely hard to spot, not to say impossible, because it could be due to a mismatch of the AST we create and how the AST depending on the project tsconfig.json should actually look like.

Main areas which are mainly impacted by this settings are: supported TS-Feautres, Module resolution, Typing-system and even the structure of the AST

Proposed solution

Read target, module and experimentalDecorators from root tsconfig.json and also respect possible overrides from a project-tsconfig.json (if we e.g. speak about NX monorepos).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions