-
-
Notifications
You must be signed in to change notification settings - Fork 534
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
Configure ts-node via tsconfig #921
Changes from 7 commits
7e301ef
73a76f3
91ca892
e11be56
5b57626
d14a028
973a78c
7dc0009
3fa74a5
90e059d
7050acc
b9b2f67
91f5e13
a209bdf
700a90f
80ea06c
a08b17b
75e0ede
e87dfa1
8669a49
8c3d848
367a53b
1fe66a7
dab7b57
024a7b2
5f6cdfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ coverage/ | |
.DS_Store | ||
npm-debug.log | ||
dist/ | ||
tsconfig.schema.json | ||
tsconfig.schemastore-schema.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env ts-node | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming this line doesn't work, since we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should work if you have |
||
/* | ||
* Create a complete JSON schema for tsconfig.json | ||
* by merging the schemastore schema with our ts-node additions. | ||
* This merged schema can be submitted in a pull request to | ||
* SchemaStore. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this script necessary? Why can't we specify a URL within our schema to have it already be up-to-date with the remote schema? I'm worried this will mean that every TypeScript version I'll need to be generating and releasing the updated schema. You're meant to be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, I'm generating 2 schemas. First is @G-Rath suggested patching ts-node's additions into the official file on Schemastore. This script produces that merged schema. The idea is that it would live in SchemaStore, so editors would tab-complete the ts-node fields without any configuration on the user's part. I'm not sure if they'll ever merge it, though, because if someone tab-completes the ts-node options, they'll still need to install ts-node. It could be nice publicity for the library; I dunno. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They will merge it, since it's not a breaking change (they don't reject PRs - like, ever) :) The configuration options are harmless if |
||
|
||
import axios from 'axios'; | ||
import * as Path from 'path'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Casing on |
||
import * as fs from 'fs'; | ||
|
||
async function main() { | ||
/** schemastore definition */ | ||
const schemastoreSchema = (await axios.get( | ||
'https://schemastore.azurewebsites.net/schemas/json/tsconfig.json', | ||
{ responseType: "json" } | ||
)).data; | ||
|
||
/** ts-node schema auto-generated from ts-node source code */ | ||
const typescriptNodeSchema = require('../tsconfig.schema.json'); | ||
|
||
/** Patch ts-node stuff into the schemastore definition. */ | ||
const mergedSchema = { | ||
...schemastoreSchema, | ||
definitions: { | ||
...schemastoreSchema.definitions, | ||
tsNodeDefinition: { | ||
properties: { | ||
'ts-node': { | ||
...typescriptNodeSchema.definitions.TsConfigOptions, | ||
description: typescriptNodeSchema.definitions.TsConfigSchema.properties['ts-node'].description, | ||
properties: { | ||
...typescriptNodeSchema.definitions.TsConfigOptions.properties, | ||
compilerOptions: { | ||
...typescriptNodeSchema.definitions.TsConfigOptions.properties.compilerOptions, | ||
allOf: [{ | ||
$ref: '#/definitions/compilerOptionsDefinition/properties/compilerOptions' | ||
}] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
}, | ||
allOf: [ | ||
...schemastoreSchema.allOf.slice(0, 4), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean? Why 4? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just so it gets spliced into the array at a point that looks nice. https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/tsconfig.json#L630-L631 |
||
{ "$ref": "#/definitions/tsNodeDefinition" }, | ||
...schemastoreSchema.allOf.slice(4), | ||
] | ||
}; | ||
fs.writeFileSync( | ||
Path.resolve(__dirname, '../tsconfig.schemastore-schema.json'), | ||
JSON.stringify(mergedSchema, null, 2) | ||
); | ||
} | ||
|
||
main(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Consistent dash casing is currently used.