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

[WIP] Refactoring vtk.js internals into Typescript #2459

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

floryst
Copy link
Collaborator

@floryst floryst commented Jun 6, 2022

Context

There has been interest to use Typescript internally in vtk.js, rather than just specifying the external API. Because of the exploratory nature of this MR, it will remain in draft form for now and serve as a starting point for discussion. Once interested parties are satisfied with the approach, we can begin incrementally converting parts of the codebase into typescript as needed.

An overview of what this MR contains (will be updated):

  • Fully typed macros.ts
  • Fully typed OutlineFilter
  • Fully typed ClassHierarchy

Some notes that can serve as points of discussion:

  • This will by no means supplant the work done to specify the external API. In fact, we will still need it, since the ts static analyzer cannot handle runtime-based object construction, and so specifying the external API is still required.
  • The looseness of typing the internal model (and public API) as a Record is required to support index-based access to properties in addition to dot notation.
  • Prettier currently does not run on *.ts files. If we start incrementally refactoring into using typescript fully, we will begin running prettier over typescript files. I will leave it open to discussion whether we should prettify *.d.ts files.

@jourdain @finetjul @daker @FezVrasta

IndexableModel,
} from 'vtk.js/Sources/macros';
import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData';
import { vtkObject, vtkOutputPort } from 'vtk.js/Sources/interfaces';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the IntelliSense works with the absolute path?

@daker daker mentioned this pull request Aug 9, 2022
25 tasks
@DavidBerger98
Copy link
Contributor

Just adding this from our discussion with @finetjul and @daker in #2532:

In case we want to keep the tabs in the *.d.ts files (would probably minimize the diffs if we lint them the first time), I suggest the following for .prettier.config.js:

module.exports = {
  printWidth: 80,
  singleQuote: true,
  trailingComma: 'es5',
  arrowParens: 'always',
  overrides: [
    {
      files: '*.d.ts',
      options: {
        useTabs: true,
        tabWidth: 4,
        singleQuote: false,
      },
    },
  ],
};

However, it probably doesn't make sense to have different linting rules between .js and .ts files.

deleted?: boolean;
}

interface ObjPublicAPI extends vtkObject, Record<string, Function> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about class'es? 🔢 🥺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants