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

Moving to TypeScript #1091

Open
19 of 33 tasks
ovr opened this issue Sep 14, 2020 · 2 comments
Open
19 of 33 tasks

Moving to TypeScript #1091

ovr opened this issue Sep 14, 2020 · 2 comments
Assignees
Labels
enhancement New feature proposal

Comments

@ovr
Copy link
Member

ovr commented Sep 14, 2020

Hey!

In 2020 TypeScript started to be a standard (exclude flow in fb internals 😄 ) for every project, It helps use to:

  • Speedup development (autocompletion, easy to know how to implement drivers by interfaces/abstract classes)
  • Protect errors
  • Generate true compatibility code for matrix of compatibility versions of Node.JS platform

Before We start

  1. Performance should not be affected
  2. BC should be done as deprecated notice, next code removal
  3. Dont break exists typings if they provided (merge to interfaces?)

High level iteration plan:

Scope

Due to the fact, that cube.js is not a small project, it's expected to have a plan, How to move it to TypeScript.

It's not possible to move module with dependency on another module that doesn't have typings. It's why dependency tree is useful to detect "core" modules.

Guide

  1. Generate declarations for every package automatically (1-2 base packages, it's needed to write driver on TypeScript)
  2. Introduce first driver fully on top of TS
  3. Move packages from 1st step to TS
  4. Move all packages to TS

Scope

Isolated packages

  • cubejs-cli

Frontend packages

Backend packages (base only)

Drivers

Non code

  • ESLint (support typescript)
  • Docs (a little bit of examples, how to debug?)
  • Tests

Thanks

@vincentwinkel
Copy link

Hello,
Small issue here when I build using tsc:
Screenshot 2021-10-26 at 09 37 46

    "@typescript-eslint/eslint-plugin": "^3.8.0",
    "@typescript-eslint/parser": "^3.8.0",
    "cross-env": "^7.0.2",
    "ts-node-dev": "^1.1.8",
    "tsconfig-paths": "^3.9.0",
    "type-graphql": "^1.0.0-rc.3",
    "typescript": "^3.9.7",
    "@cubejs-backend/postgres-driver": "^0.28.46",
    "@cubejs-backend/server-core": "^0.28.46"

@reify-thomas-smith
Copy link
Contributor

I've taken a few stabs at converting both cubejs-client-core and cubejs-client-react. This is what I've learned:

  • The Rollup config doesn't correctly handle file extensions other than .js. (This didn't cause problems for cubejs-client-ws-transport because it doesn't import any .ts files.) PR Refactor Rollup config, fix warnings, and support more file extensions #4541 would fix this, as well as a number of build warnings.
  • The Rollup config processes TypeScript files by running them through @babel/preset-typescript. I think that this would not catch type errors. Probably we should use e.g. @rollup/plugin-typescript to transpile TypeScript instead of using Babel.
  • The TypeDoc scripts currently only look at index.d.ts files. These scripts would presumably need to be modified.
  • In addition, if TypeDoc uses the declared types, then it's possible that when we use more detailed types, some tweaking might be necessary to keep the output readable.
  • The tests for cubejs-client-core are run directly on the source code, not on the compiled bundle. The test config would probably need an update to support TypeScript. The same is likely true of other packages with tests.

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

No branches or pull requests

3 participants