Skip to content

Commit

Permalink
fix(imports): add import assertions required in node since 17.5.0.
Browse files Browse the repository at this point in the history
We actually want the new `with` keyword (vs `assert`, except, it's
not recognized in older node versions, so, we need to continue to
use `assert` for the foreseeable future until all those old versions
are no longer maintained.
  • Loading branch information
gadicc committed Aug 12, 2024
1 parent c58c84b commit 7d0deea
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"lint": "eslint . --ext .js,.ts",
"timeseries": "node --loader ts-node/esm scripts/timeseries.js",
"build": "yarn run build:esm && yarn run build:cjs",
"build:esm": "tsc --module es2020 --target es2019 --outDir dist/esm",
"build:esm": "tsc --module esnext --target es2019 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es2015 --outDir dist/cjs && sed 's/\"type\": \"module\",/\"type:\": \"commonjs\",/' dist/cjs/package.json > dist/cjs/package-changed.json && mv dist/cjs/package-changed.json dist/cjs/package.json",
"prepublishOnly": "yarn build",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/getCrumb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { RequestInfo, RequestInit, Response } from "node-fetch";
import type { ExtendedCookieJar } from "./cookieJar";
import pkg from "../../package.json";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: we have to ignore this for csm output.
import pkg from "../../package.json" assert { type: "json" };
import { Logger } from "./options.js";
import { Cookie } from "tough-cookie";
import { showNotice } from "./notices.js";
Expand Down
4 changes: 3 additions & 1 deletion src/lib/validateAndCoerceTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pkg from "../../package.json";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: we have to ignore this for csm output.
import pkg from "../../package.json" assert { type: "json" };
import { FailedYahooValidationError, InvalidOptionsError } from "./errors.js";
import { StaticDecode, type TSchema } from "@sinclair/typebox";
import {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/yahooFinanceFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type { YahooFinanceOptions } from "./options.js";
import type { QueueOptions } from "./queue.js";

import errors from "./errors.js";
import pkg from "../../package.json";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: we have to ignore this for csm output.assert
import pkg from "../../package.json" assert { type: "json" };
import getCrumb from "./getCrumb.js";

const userAgent = `${pkg.name}/${pkg.version} (+${pkg.repository})`;
Expand Down
4 changes: 3 additions & 1 deletion src/modules/fundamentalsTimeSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type {
ModuleOptionsWithValidateFalse,
ModuleThis,
} from "../lib/moduleCommon.js";
import Timeseries_Keys from "../lib/timeseries.json";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: we have to ignore this for csm output.
import Timeseries_Keys from "../lib/timeseries.json" assert { type: "json" };
import { YahooFinanceDate, YahooNumber } from "../lib/yahooFinanceTypes.js";

const FundamentalsTimeSeries_Types = ["quarterly", "annual", "trailing"];
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"compilerOptions": {
"moduleResolution": "node",
"module": "es2020",
"module": "esnext",
"target": "es2020",
"outDir": "dist/default",
"allowJs": true,
Expand Down

0 comments on commit 7d0deea

Please sign in to comment.