[typescript] add typescript support for the server and browser#19104
[typescript] add typescript support for the server and browser#19104spalger merged 16 commits intoelastic:masterfrom
Conversation
d0e0866 to
6811044
Compare
45bf3c2 to
3a8a7ff
Compare
3a8a7ff to
8b3c446
Compare
a60da73 to
90210f8
Compare
90210f8 to
df586a0
Compare
💚 Build Succeeded |
💚 Build Succeeded |
|
@epixa RE no type checking in dev. This was included in a previous version of the description and I've added it back. Type checking is not supplied by the optimizer or babel-register. Adding type checking here causes things to run out of memory even on very small workloads, so instead editor integrations are leaned on for type checking information. Like you discovered, the build is the final gate and a full type-checking is done there. |
|
@tylersmalley the root Line 4 in bd0f4e1 |
|
@spalger, that did the trick. From the |
💚 Build Succeeded |
@spalger Any reason why we wouldn't just do that from the start? |
I think I'm OK with this at least initially. It's not ideal, and maybe this is something we can fix down the line, perhaps with an upgrade of babel and/or webpack. On the fly type checking is certainly useful and expected with statically typed languages, and clearly it's possible since my editor tree is handling it. But let's not block progress for the sake of things we can do down the line. |
💚 Build Succeeded |
|
I gave this a try with a greenfield kibana plugin written in typescript and was able to adapt it such that the following worked:
In doing so I stumbled across a few things:
Not tested:
Overall, great progress with a few kinks to iron out 😍 |
…ic#19104) * [typescript] add typescript support for the server and browser * [ts-jest] upgrade to latest version * [jest] support test.tsx files * [jest/ts] modify `ts-jest.tsConfigFile` config based on filePath * [types] use correct major version of minimatch types * [jest] add ts support to x-pack jest config * [ts/projects] fix tsconfig.json not found error message * [optimizer/ts] use lowercase jsx option * [tsconfig] remove ui/* alias * [plguin-helpers] remove mention of `buildSourcePatterns` * [plugin-helpers] expect typescript to be a devDep * [dev/build] place transpile tasks next to each other * [ts/x-pack] add common and server directories to ts project * [dev/ts/project] use a limited set of globs to find tsconfig files
|
6.x/6.4: 07f4e5a |
| "server/**/*", | ||
| "plugins/**/*" | ||
| ] | ||
| } |
There was a problem hiding this comment.
@spalger Ever since this file was added vscode has been complaining about errors in the workspace:
[ts] No inputs were found in config file '/Users/sqren/elastic/kibana/x-pack/tsconfig.json'. Specified 'include' paths were '["common/**/*","server/**/*","plugins/**/*"]' and 'exclude' paths were '[]'.
Any idea how to fix this?
There was a problem hiding this comment.
@sqren this is probably because there aren't actually any ts files in the x-pack project yet.. Maybe you should convert something small in APM to typescript 😄 or we can remove the tsconfig.json file for now.
Part of #18780
This PR enables TypeScript support in both the server and the client. It does not implement
tslint, that will come in #19105 .Here is a summary of how this works:
.tsand.tsxfiles are converted to.jsfiles in place.js**/*.ts,**/*.tsx,**/*.d.tsand**/tsconfig.jsonfiles are stripped from the build after successful compilationtsconfig.jsonfile at their root will be transpiled like Kibana is and have TS files stripped while buildingbabel-registerto auto-transpile.tsfiles in the server/jest/mocha.tsand.tsxfiles in webpack (without checking types)To test this out grab a file and convert it to TypeScript. I find
constants.jsfiles to be easiest: