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

Implement typescript support #18992

Closed
wants to merge 1 commit into from

Conversation

spalger
Copy link
Contributor

@spalger spalger commented May 11, 2018

Closes #18780

This PR enables TypeScript support in both the server and the client. Here is a summary of how this works:

  • distributable
    • does not have any capacity to run TypeScript
    • all TS transpilation must happen at build time before shipping distributable
  • building
    • .ts and .tsx files are converted to .js
    • Full type-check is run while TS is transpiled into .js
    • **/*.ts, **/*.tsx, **/*.d.ts and **/tsconfig.json files are stripped from the build after successful compilation
  • plugin helpers
    • plugins with a tsconfig.json file at their root will be transpiled and have TS files stripped while building
  • development
    • ts-node added to babel-register to auto-transpile .ts files in the server/jest/mocha
    • ts-loader transpiles .ts and .tsx files in webpack (without checking types)
    • Editor integrations provide type-checking feedback to developers (vscode, atom, vim, webstorm)
    • node scripts/tslint lints all typescript projects with tslint
    • pre-commit hook lints modified .ts, .tsx, and .d.ts files (just like .js files)

notes:

  • node scripts/tslint can take specific files/globs as arguments to focus on those files, and/or a --project path/to/tsconfig.json flag to focus on files associated with a specific tsconfig.json file.
  • Rather than "linting all typescript files" we "lint all typescript projects", which are defined with tsconfig.json files.
    const PROJECT_PATHS = [
    require.resolve('../../../tsconfig.json'),
    require.resolve('../../../x-pack/tsconfig.json'),
    require.resolve('../../../packages/kbn-dev-utils/tsconfig.json'),
    require.resolve('../../../packages/kbn-pm/tsconfig.json'),
    require.resolve('../../../packages/kbn-system-loader/tsconfig.json'),
    ];
    is the master list of tsconfig files, so we don't have to go searching for them all the time. By linting "projects" instead of individual files we allow the use of type-enabled linting rules, like https://palantir.github.io/tslint/rules/no-unused-variable
  • Once babel 7 is released we will remove ts-node/ts-loader and just transform TS to JS with babel

@spalger spalger added WIP Work in progress Team:Operations Team label for Operations Team labels May 11, 2018
@spalger spalger force-pushed the implement/typescript branch 2 times, most recently from d94d0a8 to fed4e8c Compare May 11, 2018 00:30
@elastic elastic deleted a comment from elasticmachine May 11, 2018
@spalger spalger changed the title Implement typescript support in the optimizer Implement typescript support May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@elastic elastic deleted a comment from elasticmachine May 15, 2018
@spalger spalger added review v7.0.0 v6.4.0 and removed WIP Work in progress labels May 16, 2018
@spalger spalger requested review from tylersmalley, epixa, timroes, azasypkin, rhoboat and stacey-gammon and removed request for tylersmalley and epixa May 16, 2018 00:52
@spalger spalger added WIP Work in progress and removed review labels May 16, 2018
@elastic elastic deleted a comment from elasticmachine May 16, 2018
@elastic elastic deleted a comment from elasticmachine May 16, 2018
@spalger
Copy link
Contributor Author

spalger commented May 16, 2018

I'm going to break this up a bit and resubmit without all this noise from @elasticmachine

@spalger spalger closed this May 16, 2018
@elasticmachine
Copy link
Contributor

💔 Build Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Operations Team label for Operations Team v6.4.0 v7.0.0 WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants