Skip to content

Commit

Permalink
TODO: Failing test that should pass
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed May 24, 2023
1 parent ebf9f85 commit 8fe03bc
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
env:
CI: true
FORCE_COLOR: 1
- name: Compile TS code
run: yarn lerna run tsc

# TS must run before we check dependencies since otherwise our exports map points to nothing.
- name: Typescript
Expand Down
54 changes: 37 additions & 17 deletions packages/canary/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"name": "@inquirer/canary",
"type": "module",
"version": "0.0.27-alpha.0",
"description": "Inquirer input text prompt",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "./dist/cjs/index.js",
"typings": "./dist/cjs/types/index.d.cts",
"files": [
"dist/"
"dist/**/*"
],
"repository": "SBoudrias/Inquirer.js",
"repository": {
"type": "git",
"url": "https://github.com/SBoudrias/Inquirer.js.git"
},
"keywords": [
"answer",
"answers",
"ask",
"base",
"cli",
"cli",
"command",
"command-line",
"confirm",
Expand Down Expand Up @@ -53,22 +54,41 @@
"license": "MIT",
"homepage": "https://github.com/SBoudrias/Inquirer.js",
"dependencies": {
"@inquirer/checkbox": "^0.0.30-alpha.0",
"@inquirer/confirm": "^0.0.28-alpha.0",
"@inquirer/core": "^0.0.30-alpha.0",
"@inquirer/editor": "^0.0.21-alpha.0",
"@inquirer/expand": "^0.0.28-alpha.0",
"@inquirer/input": "^0.0.28-alpha.0",
"@inquirer/password": "^0.0.28-alpha.0",
"@inquirer/rawlist": "^0.0.11-alpha.0",
"@inquirer/select": "^0.0.29-alpha.0",
"@inquirer/type": "^0.0.4-alpha.0",
"@inquirer/checkbox": "^1.2.8",
"@inquirer/confirm": "^1.0.11",
"@inquirer/core": "^1.3.0",
"@inquirer/editor": "^1.0.11",
"@inquirer/expand": "^1.0.11",
"@inquirer/input": "^1.1.2",
"@inquirer/password": "^1.0.11",
"@inquirer/rawlist": "^1.1.3",
"@inquirer/select": "^1.1.7",
"@inquirer/type": "^1.0.5",
"lodash": "^4.17.21"
},
"scripts": {
"tsc": "tsc"
"tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs",
"clean": "rm -rf dist",
"tsc:esm": "tsc -p ./tsconfig.json",
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && yarn run fix-ext",
"fix-ext": "node --no-warnings=ExperimentalWarning --loader=ts-node/esm ../../tools/fix-ext.mts"
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=14.18.0"
},
"exports": {
".": {
"import": {
"types": "./dist/esm/types/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/types/index.d.cts",
"default": "./dist/cjs/index.js"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/canary/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function createPromptModule() {
select,
};

type GetPrompt<U extends keyof typeof promptStore> = typeof promptStore[U];
type GetPrompt<U extends keyof typeof promptStore> = (typeof promptStore)[U];
type GetAnswerType<U extends keyof typeof promptStore> = GetPrompt<U> extends Prompt<
infer Answer,
any
Expand Down
11 changes: 11 additions & 0 deletions packages/canary/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"include": ["./src"],
"compilerOptions": {
"lib": ["ES6"],
"target": "es6",
"moduleResolution": "node",
"outDir": "dist/cjs",
"declarationDir": "dist/cjs/types"
}
}
10 changes: 7 additions & 3 deletions packages/canary/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": "../../tsconfig.json",
"include": ["./src"],
"compilerOptions": {
"outDir": "./dist",
},
"include": ["./src"]
"lib": ["ESNext"],
"target": "es2022",
"moduleResolution": "nodenext",
"outDir": "dist/esm",
"declarationDir": "dist/esm/types"
}
}
22 changes: 22 additions & 0 deletions packages/canary/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,26 @@ describe('Library types work properly', () => {
]);
}).toBeInstanceOf(Function);
});

it('register prompt', () => {
expect(() => {
inquirer.prompt([
{
/* @ts-expect-error: this prompt doesn't exist */
type: 'unknown-prompt',
name: 'ask_last_name',
message: 'Are you willing to share your last name',
},
]);

inquirer.registerPrompt('unknown-prompt', {} as any);
inquirer.prompt([
{
type: 'unknown-prompt',
name: 'ask_last_name',
message: 'Are you willing to share your last name',
},
]);
}).toBeInstanceOf(Function);
});
});

0 comments on commit 8fe03bc

Please sign in to comment.