-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
152 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Typescript Interop | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
ts-interop-test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
package-json-type: | ||
- commonjs | ||
- module | ||
tsconfig-json-module: | ||
- CommonJS | ||
- ESNext | ||
- Node16 | ||
- Nodenext | ||
tsconfig-json-module-resolution: | ||
- Node | ||
- Node16 | ||
- Nodenext | ||
exclude: | ||
- package-json-type: commonjs | ||
tsconfig-json-module: ESNext | ||
- package-json-type: module | ||
tsconfig-json-module: CommonJS | ||
- package-json-type: module | ||
tsconfig-json-module: Node16 | ||
tsconfig-json-module-resolution: Node | ||
- package-json-type: module | ||
tsconfig-json-module: NodeNext | ||
tsconfig-json-module-resolution: Node | ||
|
||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: | | ||
npm install --ignore-scripts && | ||
npm link && | ||
node scripts/create-ts-interop-test && | ||
cd test_interop && | ||
npm i --ignore-scripts && | ||
npm link fast-querystring && | ||
npm run test-interop | ||
env: | ||
PACKAGE_JSON_TYPE: ${{ matrix.package-json-type }} | ||
TSCONFIG_MODULE: ${{ matrix.tsconfig-json-module }} | ||
TSCONFIG_MODULE_RESOLUTION: ${{ matrix.tsconfig-json-module-resolution }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
coverage | ||
package-lock.json | ||
test_interop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ benchmark | |
.idea | ||
.github | ||
rome.json | ||
scripts | ||
test_interop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
declare namespace FastQuerystring { | ||
type FastQueryString = { | ||
stringify(value: Record<string, any>): string; | ||
parse(value: string): Record<string, any>; | ||
}; | ||
|
||
declare namespace fastQueryString { | ||
export function stringify(value: Record<string, any>): string; | ||
export function parse(value: string): Record<string, any>; | ||
|
||
const fqs: FastQueryString; | ||
export { fqs as default }; | ||
} | ||
|
||
export function stringify(value: Record<string, any>): string; | ||
export function parse(value: string): Record<string, any>; | ||
export default FastQuerystring; | ||
export = fastQueryString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env node | ||
const path = require("path"); | ||
const fs = require("fs").promises; | ||
|
||
const packageJsonType = | ||
process.argv[2] || process.env.PACKAGE_JSON_TYPE || "commonjs"; | ||
const tsconfigModule = process.argv[2] || process.env.TSCONFIG_MODULE || "Node"; | ||
const tsconfigModuleResolution = | ||
process.argv[2] || process.env.TSCONFIG_MODULE_RESOLUTION || "Node"; | ||
|
||
const rootPath = path.join(__dirname, ".."); | ||
const testPath = path.join(rootPath, "test_interop"); | ||
|
||
const indexTs = `import fastQuerystring from 'fast-querystring' | ||
import { stringify, parse } from 'fast-querystring' | ||
import * as fQuerystring from 'fast-querystring' | ||
import { equal } from "assert" | ||
equal(typeof fastQuerystring, 'object') | ||
equal(typeof fastQuerystring.stringify, 'function') | ||
equal(typeof fastQuerystring.parse, 'function') | ||
equal(typeof fQuerystring.stringify, 'function') | ||
equal(typeof fQuerystring.parse, 'function') | ||
equal(typeof stringify, 'function') | ||
equal(typeof parse, 'function') | ||
`; | ||
|
||
const tsconfigJson = JSON.stringify( | ||
{ | ||
compilerOptions: { | ||
module: tsconfigModule, | ||
moduleResolution: tsconfigModuleResolution, | ||
}, | ||
}, | ||
null, | ||
2, | ||
); | ||
|
||
const packageJson = JSON.stringify( | ||
{ | ||
name: "fqs-test", | ||
version: "1.0.0", | ||
description: "", | ||
main: "index.js", | ||
type: packageJsonType, | ||
scripts: { | ||
"test-interop": "tsc -p . && node index.js", | ||
}, | ||
keywords: [], | ||
author: "", | ||
license: "ISC", | ||
dependencies: { | ||
"@types/node": "^18.11.10", | ||
typescript: "^4.9.3", | ||
}, | ||
}, | ||
null, | ||
2, | ||
); | ||
|
||
async function main() { | ||
await fs.mkdir(testPath); | ||
await fs.writeFile(path.join(testPath, "package.json"), packageJson); | ||
await fs.writeFile(path.join(testPath, "tsconfig.json"), tsconfigJson); | ||
await fs.writeFile(path.join(testPath, "index.ts"), indexTs); | ||
} | ||
|
||
main(process.argv).catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |