Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/repl-omit-define-import-when-tra…
Browse files Browse the repository at this point in the history
…nspileonly' into repl-omit-define-import-when-transpileonly
  • Loading branch information
cspotcode committed Jan 21, 2022
2 parents 4f832e1 + 4ba284c commit efa941f
Show file tree
Hide file tree
Showing 20 changed files with 259 additions and 231 deletions.
1 change: 1 addition & 0 deletions dist-raw/node-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports.codes = {
ERR_PACKAGE_PATH_NOT_EXPORTED: createErrorCtor(joinArgs('ERR_PACKAGE_PATH_NOT_EXPORTED')),
ERR_UNSUPPORTED_DIR_IMPORT: createErrorCtor(joinArgs('ERR_UNSUPPORTED_DIR_IMPORT')),
ERR_UNSUPPORTED_ESM_URL_SCHEME: createErrorCtor(joinArgs('ERR_UNSUPPORTED_ESM_URL_SCHEME')),
ERR_UNKNOWN_FILE_EXTENSION: createErrorCtor(joinArgs('ERR_UNKNOWN_FILE_EXTENSION')),
}

function joinArgs(name) {
Expand Down
8 changes: 2 additions & 6 deletions esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ const require = createRequire(fileURLToPath(import.meta.url));

/** @type {import('./dist/esm')} */
const esm = require('./dist/esm');
export const {
resolve,
load,
getFormat,
transformSource,
} = esm.registerAndCreateEsmHooks();
export const { resolve, load, getFormat, transformSource } =
esm.registerAndCreateEsmHooks();
8 changes: 2 additions & 6 deletions esm/transpile-only.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ const require = createRequire(fileURLToPath(import.meta.url));

/** @type {import('../dist/esm')} */
const esm = require('../dist/esm');
export const {
resolve,
load,
getFormat,
transformSource,
} = esm.registerAndCreateEsmHooks({ transpileOnly: true });
export const { resolve, load, getFormat, transformSource } =
esm.registerAndCreateEsmHooks({ transpileOnly: true });
68 changes: 25 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@
"lodash": "^4.17.15",
"ntypescript": "^1.201507091536.1",
"nyc": "^15.0.1",
"prettier": "^2.2.1",
"prettier": "^2.5.1",
"proper-lockfile": "^4.1.2",
"proxyquire": "^2.0.0",
"react": "^16.14.0",
"rimraf": "^3.0.0",
"semver": "^7.1.3",
"throat": "^6.0.1",
"typedoc": "^0.22.4",
"typescript": "4.4.3",
"typedoc": "^0.22.10",
"typescript": "4.5.2",
"typescript-json-schema": "^0.51.0",
"util.promisify": "^1.0.1"
},
Expand Down
7 changes: 2 additions & 5 deletions scripts/create-merged-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ async function main() {
.compilerOptions,
allOf: [
{
$ref:
'#/definitions/compilerOptionsDefinition/properties/compilerOptions',
$ref: '#/definitions/compilerOptionsDefinition/properties/compilerOptions',
},
],
},
Expand All @@ -62,9 +61,7 @@ async function main() {
}

export async function getSchemastoreSchema() {
const {
data: schemastoreSchema,
} = await axios.get(
const { data: schemastoreSchema } = await axios.get(
'https://schemastore.azurewebsites.net/schemas/json/tsconfig.json',
{ responseType: 'json' }
);
Expand Down
2 changes: 1 addition & 1 deletion src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export function main(
}

if (showConfig) {
const ts = (service.ts as any) as TSInternal;
const ts = service.ts as any as TSInternal;
if (typeof ts.convertToTSConfig !== 'function') {
console.error(
'Error: --show-config requires a typescript versions >=3.2 that support --showConfig'
Expand Down
22 changes: 12 additions & 10 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import type { TSInternal } from './ts-compiler-types';
import { createTsInternals } from './ts-internals';
import { getDefaultTsconfigJsonForNodeVersion } from './tsconfigs';
import { assign, createRequire, trace } from './util';
import { assign, createRequire } from './util';

/**
* TypeScript compiler option values required by `ts-node` which cannot be overridden.
Expand Down Expand Up @@ -94,6 +94,7 @@ export function readConfig(
readFile = ts.sys.readFile,
skipProject = DEFAULTS.skipProject,
project = DEFAULTS.project,
tsTrace = DEFAULTS.tsTrace,
} = rawApiOptions;

// Read project configuration when available.
Expand Down Expand Up @@ -137,11 +138,11 @@ export function readConfig(
readDirectory: ts.sys.readDirectory,
readFile,
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
trace,
trace: tsTrace,
},
bp,
errors,
((ts as unknown) as TSInternal).createCompilerDiagnostic
(ts as unknown as TSInternal).createCompilerDiagnostic
);
if (errors.length) {
return {
Expand All @@ -164,8 +165,9 @@ export function readConfig(
const optionBasePaths: OptionBasePaths = {};
for (let i = configChain.length - 1; i >= 0; i--) {
const { config, basePath, configPath } = configChain[i];
const options = filterRecognizedTsConfigTsNodeOptions(config['ts-node'])
.recognized;
const options = filterRecognizedTsConfigTsNodeOptions(
config['ts-node']
).recognized;

// Some options are relative to the config file, so must be converted to absolute paths here
if (options.require) {
Expand Down Expand Up @@ -249,9 +251,7 @@ export function readConfig(
* Given the raw "ts-node" sub-object from a tsconfig, return an object with only the properties
* recognized by "ts-node"
*/
function filterRecognizedTsConfigTsNodeOptions(
jsonObject: any
): {
function filterRecognizedTsConfigTsNodeOptions(jsonObject: any): {
recognized: TsConfigOptions;
unrecognized: any;
} {
Expand Down Expand Up @@ -302,7 +302,9 @@ function filterRecognizedTsConfigTsNodeOptions(
swc,
};
// Use the typechecker to make sure this implementation has the correct set of properties
const catchExtraneousProps: keyof TsConfigOptions = (null as any) as keyof typeof filteredTsConfigOptions;
const catchMissingProps: keyof typeof filteredTsConfigOptions = (null as any) as keyof TsConfigOptions;
const catchExtraneousProps: keyof TsConfigOptions =
null as any as keyof typeof filteredTsConfigOptions;
const catchMissingProps: keyof typeof filteredTsConfigOptions =
null as any as keyof TsConfigOptions;
return { recognized: filteredTsConfigOptions, unrecognized };
}
Loading

0 comments on commit efa941f

Please sign in to comment.